mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-22 13:18:28 +00:00
scripts/ext_copy.py: add option to copy directly to the document directory
When this option is not given, as it happened before, the copier will create/use a subdirectory in the target final directory
This commit is contained in:
parent
29a735463a
commit
6b092c8400
@ -9,10 +9,10 @@
|
||||
# Full author contact details are available in file CREDITS
|
||||
|
||||
# Usage:
|
||||
# ext_copy.py [-e ext1,ext2,...] <from file> <to file>
|
||||
# ext_copy.py [-d] [-e ext1,ext2,...] [-t target_ext] from_file to_file
|
||||
|
||||
# This script is to be used as a "copier" script in the sense needed by
|
||||
# the converter definitions. Given a <from file> and <to file>, it will copy
|
||||
# the converter definitions. Given a from_file and to_file, it will copy
|
||||
# all files in the directory in which from_file is found that have the
|
||||
# extensions given in the -e argument, or all files in that directory if no
|
||||
# such argument is given. So, for example, we can do:
|
||||
@ -21,24 +21,32 @@
|
||||
# (possibly new) directory /path/to/file.html.LyXconv/.
|
||||
# The -t argument determines the extension added, the default being "LyXconv".
|
||||
# If just . is given, no extension is added.
|
||||
# If the -d option is given then the document directory /path/to/ will be used
|
||||
# to copy the files no subdirectory will be created/used.
|
||||
|
||||
import getopt, os, shutil, sys
|
||||
from lyxpreview_tools import error
|
||||
|
||||
|
||||
def usage(prog_name):
|
||||
return "Usage: %s [-e extensions] [-t target extension] <from file> <to file>" % prog_name
|
||||
msg = "Usage: %s [-d] [-e extensions] [-t target extension] from_file to_file"
|
||||
return msg % prog_name
|
||||
|
||||
|
||||
def main(argv):
|
||||
progname = argv[0]
|
||||
|
||||
exts = [] #list of extensions for which we're checking
|
||||
use_doc_dir = False
|
||||
targext = "LyXconv" #extension for target directory
|
||||
opts, args = getopt.getopt(sys.argv[1:], "e:t:")
|
||||
opts, args = getopt.getopt(sys.argv[1:], "de:t:")
|
||||
for o, v in opts:
|
||||
if o == "-e":
|
||||
exts = v.split(',')
|
||||
if o == "-t":
|
||||
targext = v
|
||||
if o == "-d":
|
||||
use_doc_dir = True
|
||||
|
||||
# input directory
|
||||
if len(args) != 2:
|
||||
@ -49,6 +57,9 @@ def main(argv):
|
||||
from_dir = os.path.dirname(abs_from_file)
|
||||
|
||||
# output directory
|
||||
if use_doc_dir:
|
||||
to_dir = os.path.dirname(args[1])
|
||||
else:
|
||||
to_dir = args[1]
|
||||
if targext != '.':
|
||||
to_dir += "." + targext
|
||||
|
Loading…
Reference in New Issue
Block a user