Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 7752f73

Browse files
committed
latex configure
1 parent 9367458 commit 7752f73

File tree

3 files changed

+19
-14
lines changed

3 files changed

+19
-14
lines changed

src/codebots/bots/latexbot.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class LatexBot(BaseBot):
2222
def __init__(self, config_file=None, sender=None) -> None:
2323
self.__name__ = "latexbot"
2424

25-
def install_dependencies(self, **kwargs):
25+
def install_dependencies(self, git, pandoc, miktex):
2626
"""Installs the dependencies needed, namely:
2727
- git
2828
- pandoc 2.15
@@ -35,11 +35,11 @@ def install_dependencies(self, **kwargs):
3535
Kwargs
3636
------
3737
git : bool, optional
38-
install git if not already present, by default True
38+
install git if not already present
3939
pandoc : bool, optional
40-
install pandoc if not already present, by default True
41-
latex : bool, optional
42-
install latex (miktex distribution) if not already present, by default False
40+
install pandoc if not already present
41+
miktex : bool, optional
42+
install latex (miktex distribution) if not already present
4343
4444
Raises
4545
------
@@ -63,21 +63,20 @@ def install_dependencies(self, **kwargs):
6363
{'url': 'https://github.com/git-for-windows/git/releases/download/v2.33.1.windows.1/Git-2.33.1-64-bit.exe',
6464
'function': 'install_exe',
6565
'file_name': 'git.exe'},
66-
'latex':
66+
'miktex':
6767
{'url': 'https://miktex.org/download/ctan/systems/win32/miktex/setup/windows-x64/basic-miktex-21.8-x64.exe',
6868
'function': 'install_exe',
6969
'file_name': 'miktex.exe'}
7070
}
7171
for tool, parameter in settings.items():
7272
file_path = Path().joinpath(temp_dir.name, parameter['file_name'])
73-
if not os_tools.is_tool(tool) and kwargs[tool]:
73+
if not os_tools.is_tool(tool) and locals()[tool]:
7474
print(f'downloading {tool}')
7575
download_file(url=parameter['url'],
7676
file_path=file_path)
7777
print(f'installing {tool}')
7878
installation_function = getattr(os_tools, parameter['function'])
7979
installation_function(file_path=file_path)
80-
# install_msi(file_path=file_path)
8180

8281
else:
8382
print(f'{tool} skipped or already installed')

src/codebots/cli/cli.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -364,17 +364,20 @@ def latexbot():
364364

365365

366366
@latexbot.command()
367-
def configure():
367+
@click.option('--git', default=True, help='if True, install git')
368+
@click.option('--pandoc', default=True, help='if True, install pandoc')
369+
@click.option('--miktex', default=False, help='if True, install miktex')
370+
def configure(git, pandoc, miktex):
368371
"""Download dependencies and set everything up.\n
369372
"""
370373
bot = LatexBot()
371-
out = bot.install_dependencies(git=True, pandoc=True, latex=False)
374+
out = bot.install_dependencies(git, pandoc, miktex)
372375
click.echo(out)
373376

374377

375378
@latexbot.command()
376-
@click.option('--input', default='None', help='path to the folder containing the .tex files')
377-
@click.option('--output', default='None', help='path to the folder where the .docx files will be saved')
379+
@click.option('--input', default=None, help='path to the folder containing the .tex files')
380+
@click.option('--output', default=None, help='path to the folder where the .docx files will be saved')
378381
def convert_tex_to_docx(input, output):
379382
"""Convert the .tex files in a folder to .docx.\n
380383
@@ -384,9 +387,9 @@ def convert_tex_to_docx(input, output):
384387
path to the folder containing the .tex files.\n
385388
"""
386389
bot = LatexBot()
387-
if input == 'None':
390+
if not input:
388391
input = os.getcwd()
389-
if output == 'None':
392+
if not output: # TODO: change!
390393
output = None
391394
out = bot.convert_tex_to_docx(input, output)
392395
click.echo(out)

src/codebots/utilities/os_tools.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import subprocess
22

33

4+
### ------------------------ CROSS PLATFORM ---------------------------------###
45
def is_tool(name):
56
"""Check whether `name` is on PATH and marked as executable."""
67

@@ -10,6 +11,7 @@ def is_tool(name):
1011
return which(name) is not None
1112

1213

14+
### ---------------------------- WINDOWS ------------------------------------###
1315
def install_msi(file_path):
1416
"""Perform a silent install of a msi package (Windows only)
1517
@@ -49,6 +51,7 @@ def install_exe(file_path):
4951
return out
5052

5153

54+
### ------------------------------ DEBUG ------------------------------------###
5255
if __name__ == "__main__":
5356
# print(is_tool("latexmk"))
5457
install_exe('c:/temp/miktex.exe')

0 commit comments

Comments
 (0)