Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
H
hdd29-CS265-sp19
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
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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
hdd29
hdd29-CS265-sp19
Commits
8f7baf0c
Commit
8f7baf0c
authored
6 years ago
by
hdd29
Browse files
Options
Downloads
Patches
Plain Diff
Final commit
parent
3e8506b8
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
assn2/dropXml.py
+34
-23
34 additions, 23 deletions
assn2/dropXml.py
with
34 additions
and
23 deletions
assn2/dropXml.py
+
34
−
23
View file @
8f7baf0c
...
...
@@ -18,12 +18,14 @@ def checkType(foo, dirXML):
stat
.
S_ISFIFO
:
'
fifo
'
,
stat
.
S_ISSOCK
:
'
sock
'
}
try
:
mode
=
os
.
stat
(
foo
)[
stat
.
ST_MODE
]
for
t
,
n
in
tests
.
items
():
if
t
(
mode
):
dirXML
.
write
(
f
'
\t\t
<
{
n
}
>
{
foo
}
</
{
n
}
>
\n
'
)
break
except
FileNotFoundError
:
dirXML
.
write
(
f
'
\t\t
<file>
{
foo
}
</file>
\n
'
)
...
...
@@ -35,17 +37,20 @@ def drop(top):
for
root
,
dirs
,
files
in
os
.
walk
(
top
):
os
.
chdir
(
root
)
currentDir
=
os
.
getcwd
()
print
(
f
'
Currently walking through
{
currentDir
}
'
)
exists
=
os
.
path
.
isfile
(
str
(
currentDir
)
+
'
/README
'
)
dirXML
=
open
(
'
dir.xml
'
,
'
w
'
)
dirXML
.
write
(
'
<?xml version=
"
1.0
"
encoding=
"
ISO-8859-1
"
?>
\n
<direntry>
\n
'
)
if
exists
:
print
(
'
Found README!
\n
Parsing README ...
'
)
print
(
'
Found README!
\n
Parsing README ...
\n\n
'
)
#if exist README in that folder
RM
=
open
(
'
README
'
,
'
r
'
)
line_list
=
RM
.
readlines
()
RM
.
close
()
required
=
[]
index
=
[]
for
l
in
line_list
:
w
=
l
.
split
(
'
:
'
)
...
...
@@ -61,12 +66,14 @@ def drop(top):
required
=
w
[
1
:(
len
(
w
)
-
1
)]
required
.
append
(
last
)
if
len
(
index
)
>
0
:
dirXML
.
write
(
'
\t
<index>
\n
'
)
for
i
in
index
:
dirXML
.
write
(
f
'
\t\t
<file>
{
i
}
</file>
\n
'
)
dirXML
.
write
(
'
\t
</index>
\n
'
)
if
len
(
required
)
>
0
:
dirXML
.
write
(
'
\t
<required>
\n
'
)
for
r
in
required
:
checkType
(
r
,
dirXML
)
...
...
@@ -74,9 +81,11 @@ def drop(top):
dirXML
.
write
(
'
\t
<other>
\n
'
)
for
f
in
files
:
if
(
f
not
in
required
)
and
(
f
not
in
index
)
and
(
str
(
f
)
!=
'
dir.xml
'
):
checkType
(
f
,
dirXML
)
for
d
in
dirs
:
if
(
f
not
in
required
)
and
(
f
not
in
index
):
checkType
(
d
,
dirXML
)
...
...
@@ -84,11 +93,13 @@ def drop(top):
else
:
print
(
'
Uh uh, no README for you! All files will go to section
"
others
"'
)
print
(
'
Uh uh, no README for you! All files will go to section
"
others
"
\n\n
'
)
dirXML
.
write
(
'
\t
<other>
\n
'
)
for
root
,
dirs
,
files
in
os
.
walk
(
currentDir
):
for
f
in
files
:
if
str
(
f
)
!=
'
dir.xml
'
:
checkType
(
f
,
dirXML
)
for
d
in
dirs
:
checkType
(
d
,
dirXML
)
dirXML
.
write
(
'
\t
</other>
\n
'
)
...
...
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