Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
W
work.species-of-things
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container 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
osp
work.species-of-things
Commits
63aaa6bb
Commit
63aaa6bb
authored
8 years ago
by
gijs
Browse files
Options
Downloads
Patches
Plain Diff
Modified boxes.py so it reads an argument and exports an html clip
parent
2ff37afd
No related branches found
No related tags found
Loading
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
sketches/sketch-blokken/boxes.py
+24
-24
24 additions, 24 deletions
sketches/sketch-blokken/boxes.py
with
24 additions
and
24 deletions
sketches/sketch-blokken/boxes.py
+
24
−
24
View file @
63aaa6bb
import
re
import
urllib
import
argparse
filein
=
open
(
"
../classification-systems/TARIC-nomenclature.txt
"
,
"
r
"
)
with
open
(
"
sketch-blokken/schets-manetta4.html
"
,
"
w+
"
)
as
fileout
:
parser
=
argparse
.
ArgumentParser
()
parser
.
add_argument
(
'
input
'
,
type
=
str
,
help
=
"
The text-file to parse
"
)
parser
.
add_argument
(
'
output
'
,
type
=
str
,
help
=
"
The dot-file to store produced dot in.
"
)
args
=
parser
.
parse_args
()
fileout
.
write
(
'
<html><head><link href=
"
schets-manetta4.css
"
rel=
"
stylesheet
"
></head><body><div id=
"
main
"
>
'
)
is_url_match
=
r
'
^http(?:s)?:\/\/
'
filein
=
urllib
.
urlopen
(
args
.
input
)
if
re
.
match
(
is_url_match
,
args
.
input
)
else
open
(
args
.
input
,
'
r
'
)
with
open
(
args
.
output
,
'
w
'
)
as
fileout
:
fileout
.
write
(
'
<div id=
"
main
"
>
'
)
c
=
1
for
line
in
filein
:
for
line
in
filein
:
line
=
re
.
sub
(
'
\s{8}
'
,
'
\t
'
,
line
)
m
=
re
.
search
(
r
"
^\t*
"
,
line
)
if
m
:
tab
=
len
(
m
.
group
(
0
))
+
1
strtab
=
str
(
tab
)
line
=
line
.
replace
(
"
\t
"
,
""
)
print
line
#
print line
fontsize
=
str
(
10
);
if
line
==
'
For slaughter
\n
'
:
line
=
line
+
"
<img src=
'
../img/0106.jpg
'
>
"
if
line
==
'
Bulls of the Schwyz, Fribourg and spotted Simmental breeds
\n
'
:
line
=
line
+
"
<img src=
'
../img/https---s3.amazonaws.com-ul-hos-legacy-images-tiff-02LateAncient-Solinus-1543-Solinus-1543det-007-detail.jpg
'
>
"
if
tab
==
c
:
if
"
LIVE ANIMALS
\n
"
!=
line
:
fileout
.
write
(
'
</div>
\n
'
)
fileout
.
write
(
'
<div class=
"
h
'
+
strtab
+
'"
>
'
+
line
)
print
'
tab is same
'
print
'
c:
'
,
c
,
'
tab:
'
,
tab
#
print 'tab is same'
#
print 'c:', c, 'tab:', tab
if
tab
>
c
:
fileout
.
write
(
'
<div class=
"
h
'
+
strtab
+
'"
>
'
+
line
)
print
'
tab is bigger
'
print
'
c:
'
,
c
,
'
tab:
'
,
tab
#
print 'tab is bigger'
#
print 'c:', c, 'tab:', tab
if
tab
<
c
:
enddiv
=
'
</div>
\n
'
fileout
.
write
((
c
-
tab
+
1
)
*
enddiv
)
print
str
(
c
-
tab
+
1
)
+
'
x enddiv printed
'
#
print str(c - tab + 1)+ 'x enddiv printed'
fileout
.
write
(
'
<div class=
"
h
'
+
strtab
+
'"
>
'
+
line
)
print
'
tab is smaller
'
print
'
c:
'
,
c
,
'
tab:
'
,
tab
#
print 'tab is smaller'
#
print 'c:', c, 'tab:', tab
c
=
tab
print
'
**********************
'
fileout
.
write
(
"""
</div>
</body>
</html>
"""
)
# print '**********************'
fileout
.
write
(
'
</div>
'
)
fileout
.
close
()
\ No newline at end of file
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