Skip to content

Commit 8dbd7d0

Browse files
committed
fixes Windows-issue #25 by manually resolving file globbing (version 2019.12.22.1)
1 parent 21aa4c8 commit 8dbd7d0

File tree

2 files changed

+28
-9
lines changed

2 files changed

+28
-9
lines changed

README.org

+9-6
Original file line numberDiff line numberDiff line change
@@ -76,15 +76,17 @@ You get updates by executing the very same pip command again.
7676

7777
*** Installation Via Source Code
7878

79-
If you use the GitHub sources (and not pip), the executable is
80-
~filetags/__init__.py~. You might want to create a symbolic link named
81-
"filetags" to that file.
79+
If you use the GitHub sources (and not pip):
80+
81+
- You need to install depending packages via: ~pip install -r requirements.txt~
82+
- The executable is ~filetags/__init__.py~. You might want to create a
83+
symbolic link named "filetags" to that file.
8284

8385
** Usage
8486

85-
#+BEGIN_SRC sh :results output :wrap src
86-
./filetags/__init__.py --help | sed 'sX/home/vkX\$HOMEX'
87-
#+END_SRC
87+
# #+BEGIN_SRC sh :results output :wrap src
88+
# ./filetags/__init__.py --help | sed 'sX/home/vkX\$HOMEX'
89+
# #+END_SRC
8890

8991
#+BEGIN_src
9092
usage: ./filetags/__init__.py [-h] [-t "STRING WITH TAGS"] [--remove] [-i]
@@ -326,6 +328,7 @@ For =--filter= and =--tagtrees= examples see sections below.
326328
integration
327329
- 2018-07-23: =--tagtrees== can now be filtered with =--filter=
328330
- 2018-08-02: added option =--hardlinks= as an alternative for non-Windows systems
331+
- 2019-12-22: added manual file globbing for Windows because of [[https://github.com/novoid/filetags/issues/25][#25]]
329332

330333
** Get the most out of filetags: controlled vocabulary ~.filetags~
331334
:PROPERTIES:

filetags/__init__.py

+19-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env python3
22
# -*- coding: utf-8 -*-
3-
PROG_VERSION = "Time-stamp: <2018-08-31 19:37:34 vk>"
3+
PROG_VERSION = "Time-stamp: <2019-12-22 13:23:52 vk>"
44

55
# TODO:
66
# - fix parts marked with «FIXXME»
@@ -38,7 +38,6 @@ def save_import(library):
3838
"\".\nPlease install it, e.g., with \"sudo pip install " + library + "\".")
3939
sys.exit(2)
4040

41-
4241
import re
4342
import sys
4443
import os
@@ -60,7 +59,8 @@ def save_import(library):
6059
except ImportError:
6160
print("Could not find Python module \"win32com.client\".\nPlease install it, e.g., " +
6261
"with \"sudo pip install pypiwin32\".")
63-
sys.exit(2)
62+
sys.exit(3)
63+
save_import('pathlib')
6464

6565
PROG_VERSION_DATE = PROG_VERSION[13:23]
6666
# unused: INVOCATION_TIME = time.strftime("%Y-%m-%dT%H:%M:%S", time.localtime())
@@ -2468,6 +2468,22 @@ def main():
24682468

24692469
files = extract_filenames_from_argument(options.files)
24702470

2471+
if platform.system() == 'Windows' and len(files)==1:
2472+
# Windows CLI does not resolve wildcard globbing: https://github.com/novoid/filetags/issues/25
2473+
# Therefore, filetags has to do the business proper(TM) operating systems usually
2474+
# does: converting file globs to lists of files:
2475+
2476+
#logging.debug("WINDOWS: files[0] RAW [%s]" % str(files[0]))
2477+
path = pathlib.Path(files[0]).expanduser()
2478+
parts = path.parts[1:] if path.is_absolute() else path.parts
2479+
expandedfiles = pathlib.Path(path.root).glob(str(pathlib.Path("").joinpath(*parts)))
2480+
files = []
2481+
for file in expandedfiles:
2482+
#logging.debug("WINDOWS: file within expandedfiles [%s]" % str(file))
2483+
files.append(str(file))
2484+
logging.debug("WINDOWS: len(files) [%s]" % str(len(files)))
2485+
logging.debug("WINDOWS: files CONVERTED [%s]" % str(files))
2486+
24712487
global list_of_link_directories
24722488
global chosen_tagtrees_dir
24732489

0 commit comments

Comments
 (0)