Skip to content

Commit

Permalink
Support blank in path
Browse files Browse the repository at this point in the history
  • Loading branch information
ChenjieXu committed Jan 9, 2022
1 parent 6762c35 commit b1aed70
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
1.0.2 (9 Jan 2022)
- Using poetry to manage project and change structure
- Support blank in path

1.0.1 (18 April 2021)
- Fix jar preparation and add test case
Expand Down
25 changes: 13 additions & 12 deletions pyzxing/reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,26 +31,27 @@ def __init__(self):
self.lib_path = osp.join(cache_dir, build_jar_filename)
if not osp.exists(self.lib_path):
shutil.copyfile(build_jar_path[-1], self.lib_path)
return
# Check cache dir
cache_jar_path = glob.glob(osp.join(cache_dir, "javase-*-jar-with-dependencies.jar"))
if cache_jar_path:
self.lib_path = cache_jar_path[-1]
return
else:
# Download preset jar if not built or cache jar
download_url = osp.join(preset_jar_url_prefix, preset_jar_filename)
get_file(preset_jar_filename, download_url, cache_dir)
logging.debug("Download completed.")
self.lib_path = osp.join(cache_dir, preset_jar_filename)
# Check cache dir
cache_jar_path = glob.glob(osp.join(cache_dir, "javase-*-jar-with-dependencies.jar"))
if cache_jar_path:
self.lib_path = cache_jar_path[-1]
else:
# Download preset jar if not built or cache jar
download_url = osp.join(preset_jar_url_prefix, preset_jar_filename)
get_file(preset_jar_filename, download_url, cache_dir)
logging.debug("Download completed.")
self.lib_path = osp.join(cache_dir, preset_jar_filename)

self.lib_path = '"' + self.lib_path + '"' # deal with blank in path

def decode(self, filename_pattern):
filenames = glob.glob(osp.abspath(filename_pattern))
if not len(filenames):
raise FileNotFoundError

elif len(filenames) == 1:
results = self._decode(filenames[0].replace('\\', '/'))
results = self._decode(filenames[0].replace('\\', '/').replace(' ', '\ '))

else:
results = Parallel(n_jobs=-1)(
Expand Down

0 comments on commit b1aed70

Please sign in to comment.