Skip to content

Commit

Permalink
Normalize path names.
Browse files Browse the repository at this point in the history
  • Loading branch information
korenmiklos committed Feb 7, 2012
1 parent fbc5c12 commit 09c3553
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions autodoc.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,16 @@
'color': '#71B7B7'},
}

def normalize(name):
# strip whitespace and "s
name = ''.join(name.strip().split('"'))
return os.path.normpath(name)

class Node(object):
def __init__(self,filename,node_type,graph):
self.filename = filename
path, name = os.path.split(normalize(filename))
self.filename = name
self.path = path
self.node_type = node_type
# each field starst with an emtpy list
self.attributes = dict([(key, []) for key in FIELDS.keys()])
Expand Down Expand Up @@ -87,7 +94,8 @@ def add_attribute(self,text,categ):
node_direction = categ.split('_')[1] # e.g., output
if node_direction in ('input', 'output'):
# preprocessing of node
name = text.strip()
name = normalize(os.path.join(self.path,text.strip()))
# name is relative to current path
if self.graph.has_name(name):
newnode = self.graph.get_node(name)
else:
Expand All @@ -102,10 +110,10 @@ def add_attribute(self,text,categ):
def get_absolute_path(self):
pass
def get_canonical_name(self):
return self.filename
return os.path.join(self.path,self.filename)

def open_for_reading(self):
return open(self.filename,"r")
return open(os.path.join(self.path,self.filename),"r")

def get_yaml(self):
# change to verbose name
Expand Down Expand Up @@ -226,7 +234,7 @@ def read_yaml_file(self):
except:
path = './'
for infile in glob.glob( os.path.join(path, '*.do') ):
print "current file is: " + infile
print "Current file is: " + infile
dofile = DoFile(infile,graph)
dofile.extract_inputs_and_outputs()
print dofile.get_yaml()
Expand Down

0 comments on commit 09c3553

Please sign in to comment.