Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Flex Extract
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Service Desk
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Flexpart
Flex Extract
Commits
507d47f2
Commit
507d47f2
authored
Feb 5, 2018
by
Anne Philipp
Browse files
Options
Downloads
Patches
Plain Diff
pep8 changes + docs added + todo on UIOTools.py
parent
a4b6cef4
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
python/UIOTools.py
+68
-19
68 additions, 19 deletions
python/UIOTools.py
with
68 additions
and
19 deletions
python/UIOTools.py
+
68
−
19
View file @
507d47f2
...
...
@@ -8,17 +8,67 @@
# Creation: October 2014 - Anne Fouilloux - University of Oslo
#
#************************************************************************
# TODO AP
#
# - File name und Klassenname gleichsetzen?
# - checken welche regelmässigen methoden auf diese Files noch angewendet werden
# und dann hier implementieren
# - löschen?
#************************************************************************
import
os
import
glob
class
UIOFiles
:
'
class to manipulate files
'
'''
Class to manipulate files. At initialisation it has the attribute
suffix which stores a list of suffixes of the files associated
with the instance of the class.
'''
def
__init__
(
self
,
suffix
):
# type of files to manipulate such as ['.grib', 'grb', 'grib1', 'grib2', 'grb1','grb2']
'''
@Description:
Assignes the suffixes of the files which should be
associated with the instance of the class.
@Input:
self: instance of UIOFiles
Description see class documentation.
suffix: list of strings
Types of files to manipulate such as
[
'
.grib
'
,
'
grb
'
,
'
grib1
'
,
'
grib2
'
,
'
grb1
'
,
'
grb2
'
]
@Return:
<nothing>
'''
self
.
suffix
=
suffix
return
def
listFiles
(
self
,
pathname
,
pattern
):
'''
list files (suffix previously given) within this directory.
'''
'''
@Description:
Lists all files in the directory with the matching
regular expression pattern. The suffixes are already stored
in a list attribute
"
suffix
"
.
@Input:
self: instance of UIOFiles
Description see class documentation.
pathname: string
Directory where to list the files.
pattern: string
Regular expression pattern. For example:
'
*OG_acc_SL*.
'
+c.ppid+
'
.*
'
@Return:
<nothing>
'''
# Get the absolute path of the pathname parameter
pathname
=
os
.
path
.
abspath
(
pathname
)
...
...
@@ -43,7 +93,6 @@ class UIOFiles:
self
.
counter
+=
1
# add this filename in the list
self
.
files
.
append
(
curFile
)
else
:
# We got a directory, enter into it for further processing
self
.
listFiles
(
curFile
)
...
...
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