Skip to content

Commit 7c9e40c

Browse files
committed
fix bugs
1 parent 954e64d commit 7c9e40c

File tree

6 files changed

+22
-7
lines changed

6 files changed

+22
-7
lines changed

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ def get_package_data_files(package, data, package_dir=None):
8080
exclude=("examples*", "tests*", "applications*", "model_zoo*"),
8181
),
8282
package_dir={"": "./src"},
83-
package_data={},
83+
package_data={"": ["*.txt"]},
8484
setup_requires=[],
8585
install_requires=REQUIRED_PACKAGES,
8686
entry_points={},

src/bisheng_unstructured/topdf/docx2pdf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def render(self, input_file, output_file=None, to_bytes=False):
5454
class DocxToPDFV1(object):
5555
def __init__(self, kwargs={}):
5656
cmd_template = """
57-
soffice --headless --convert-to pdf --outdir {1} {0}
57+
soffice --headless --convert-to pdf --outdir \"{1}\" \"{0}\"
5858
"""
5959

6060
def _norm_cmd(cmd):

src/bisheng_unstructured/topdf/excel2pdf.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def __init__(self, kwargs={}):
1616
soffice --headless --convert-to xlsx --outdir
1717
"""
1818

19-
cmd_template3 = "sed -e 's/\t/,/g' {0} > {1}"
19+
cmd_template3 = 'sed -e \'s/\t/,/g\' "{0}" > "{1}"'
2020

2121
def _norm_cmd(cmd):
2222
return " ".join([p.strip() for p in cmd.strip().split()])
@@ -50,7 +50,7 @@ def render(self, input_file, output_file=None, to_bytes=False):
5050
type_ext = "csv"
5151

5252
if type_ext in ["xls", "csv"]:
53-
cmd = self.cmd_template2 + " {1} {0}".format(input_file, temp_dir)
53+
cmd = self.cmd_template2 + ' "{1}" "{0}"'.format(input_file, temp_dir)
5454
ExcelToPDF.run(cmd)
5555
filename = filename.rsplit(".", 1)[0] + ".xlsx"
5656
input_file = os.path.join(temp_dir, filename)
@@ -64,7 +64,7 @@ def render(self, input_file, output_file=None, to_bytes=False):
6464
input_file = os.path.join(temp_dir, filename)
6565
wb.save(input_file)
6666

67-
cmd = self.cmd_template + " {1} {0}".format(input_file, temp_dir)
67+
cmd = self.cmd_template + ' "{1}" "{0}"'.format(input_file, temp_dir)
6868
ExcelToPDF.run(cmd)
6969

7070
if output_file is not None:

src/bisheng_unstructured/topdf/pptx2pdf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
class PptxToPDF(object):
66
def __init__(self, kwargs={}):
77
cmd_template = """
8-
soffice --headless --convert-to pdf --outdir {1} {0}
8+
soffice --headless --convert-to pdf --outdir \"{1}\" \"{0}\"
99
"""
1010

1111
def _norm_cmd(cmd):

src/bisheng_unstructured/topdf/text2pdf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ def __init__(self, kwargs={}):
9898
"""
9999

100100
cmd_template2 = """
101-
soffice --headless --convert-to pdf --outdir {1} {0}
101+
soffice --headless --convert-to pdf --outdir \"{1}\" \"{0}\"
102102
"""
103103

104104
def _norm_cmd(cmd):

tests/test_cmd_with_blank_char.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import os
2+
3+
4+
def test_python_cmd_with_blank():
5+
path1 = "data/1 Folder/"
6+
cmd = """ls \"{0}\"""".format(path1)
7+
print("cmd", cmd)
8+
os.system(cmd)
9+
10+
cmd = 'ls "{0}"'.format(path1)
11+
print("cmd", cmd)
12+
os.system(cmd)
13+
14+
15+
test_python_cmd_with_blank()

0 commit comments

Comments
 (0)