Skip to content
Snippets Groups Projects
Commit bbf99b42 authored by Bruno Freitas Tissei's avatar Bruno Freitas Tissei
Browse files

Small fixes

parent a8c08bec
No related branches found
No related tags found
No related merge requests found
No preview for this file type
...@@ -5,11 +5,11 @@ class Tree: ...@@ -5,11 +5,11 @@ class Tree:
def __init__(self, dirs): def __init__(self, dirs):
self.dirs = dirs; self.dirs = dirs;
self.tree = {} self.tree = {}
self.build() self._build()
# Builds a tree represented as dict, with structure of files # Builds a tree represented as dict, with structure of files
# and directories. # and directories.
def build(self): def _build(self):
for di in self.dirs: for di in self.dirs:
path_list = list(Path(di).glob('**/*.cpp')) path_list = list(Path(di).glob('**/*.cpp'))
path_list += list(Path(di).glob('**/*.vim')) path_list += list(Path(di).glob('**/*.vim'))
...@@ -48,7 +48,8 @@ class LatexGenerator: ...@@ -48,7 +48,8 @@ class LatexGenerator:
self.header = {} self.header = {}
self.code, self.raw_header = [], [] self.code, self.raw_header = [], []
self.sections = ['Description', 'Time', 'Space', 'Include', 'Status'] self.sections = ['Description', 'Time', 'Space', 'Include',
'Status']
self._parse_source(source) self._parse_source(source)
self._parse_header() self._parse_header()
...@@ -142,7 +143,8 @@ class LatexGenerator: ...@@ -142,7 +143,8 @@ class LatexGenerator:
to_big_o(line[1].strip()))) to_big_o(line[1].strip())))
write('\\end{compactitem}\n') write('\\end{compactitem}\n')
else: else:
write('\\footnotesize{$%s$}\n' % to_big_o(self.header[comp][0])) write('\\footnotesize{$%s$}\n' %
to_big_o(self.header[comp][0]))
return True return True
return False return False
...@@ -190,7 +192,7 @@ class LatexGenerator: ...@@ -190,7 +192,7 @@ class LatexGenerator:
self._write('\\%s{%s}\n' % (self.hierarchy[depth], content)) self._write('\\%s{%s}\n' % (self.hierarchy[depth], content))
# Prints code in LaTeX format. # Prints code in LaTeX format.
def gen_code_latex(self, source): def _gen_code_latex(self, source):
source.output_header(self._write) source.output_header(self._write)
source.output_code(self._write) source.output_code(self._write)
self._write('\\hrule\n') self._write('\\hrule\n')
...@@ -201,7 +203,7 @@ class LatexGenerator: ...@@ -201,7 +203,7 @@ class LatexGenerator:
for i in sub: for i in sub:
source = self.SourceFile(path + i) source = self.SourceFile(path + i)
self._gen_title_latex(source.name, depth) self._gen_title_latex(source.name, depth)
self.gen_code_latex(source) self._gen_code_latex(source)
else: else:
if depth == 1: if depth == 1:
self._write('\\begin{multicols}{3}\n') self._write('\\begin{multicols}{3}\n')
...@@ -221,22 +223,14 @@ class LatexGenerator: ...@@ -221,22 +223,14 @@ class LatexGenerator:
# Parses command line arguments and returns them. # Parses command line arguments and returns them.
def get_args(): def get_args():
parser = argparse.ArgumentParser() parser = argparse.ArgumentParser()
parser.add_argument('--header', action='store', type=str,
parser.add_argument('--header',
action='store',
type=str,
help='Header of Latex file') help='Header of Latex file')
parser.add_argument('--output', action='store', type=str,
parser.add_argument('--output',
action='store',
type=str,
help='Output Latex file') help='Output Latex file')
return parser.parse_args() return parser.parse_args()
def main(): def main():
args = get_args() args = get_args()
tree = Tree(['algorithms', 'misc']) tree = Tree(['algorithms', 'misc'])
tex = LatexGenerator(tree, args.output, args.header) tex = LatexGenerator(tree, args.output, args.header)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment