Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
competitive
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Harbor Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Bruno Freitas Tissei
competitive
Commits
bbf99b42
Commit
bbf99b42
authored
6 years ago
by
Bruno Freitas Tissei
Browse files
Options
Downloads
Patches
Plain Diff
Small fixes
Signed-off-by:
Bruno Freitas Tissei
<
bft15@inf.ufpr.br
>
parent
a8c08bec
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
caderno.pdf
+0
-0
0 additions, 0 deletions
caderno.pdf
notebook/gen_latex.py
+10
-16
10 additions, 16 deletions
notebook/gen_latex.py
with
10 additions
and
16 deletions
caderno.pdf
+
0
−
0
View file @
bbf99b42
No preview for this file type
This diff is collapsed.
Click to expand it.
notebook/gen_latex.py
+
10
−
16
View file @
bbf99b42
...
@@ -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
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment