From 9ca82caeb779cede369a24794e66c9ab0bc80b64 Mon Sep 17 00:00:00 2001 From: Alexander Alekhin Date: Fri, 16 Nov 2018 00:23:26 +0000 Subject: [PATCH] samples(python): fix drive handling in source path --- samples/python/video.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/samples/python/video.py b/samples/python/video.py index e4eb2d3..87b45b8 100755 --- a/samples/python/video.py +++ b/samples/python/video.py @@ -32,6 +32,8 @@ Keys: # Python 2/3 compatibility from __future__ import print_function +import re + import numpy as np from numpy import pi, sin, cos @@ -169,11 +171,11 @@ def create_capture(source = 0, fallback = presets['chess']): '''source: or '||synth [:= [:...]]' ''' source = str(source).strip() + + # Win32: handle drive letter ('c:', ...) + source = re.sub(r'(^|=)([a-zA-Z]):([/\\a-zA-Z0-9])', r'\1?disk\2?\3', source) chunks = source.split(':') - # handle drive letter ('c:', ...) - if len(chunks) > 1 and len(chunks[0]) == 1 and chunks[0].isalpha(): - chunks[1] = chunks[0] + ':' + chunks[1] - del chunks[0] + chunks = [re.sub(r'\?disk([a-zA-Z])\?', r'\1:', s) for s in chunks] source = chunks[0] try: source = int(source) -- 2.7.4