コード例 #1
0
ファイル: mover.py プロジェクト: stukemanmini/ECE_Material
def hprocess(name, filedir):

    name = decrease(name, filedir)
    print "processing", name

    f = open(name, "r")
    lines = f.readlines()
    f.close()

    if not lines:
        return

    for l in lines:
        if len(l) < 10:
            continue
        if l[0] != "#":
            continue
        if l[:9] != "#include ":
            continue
        hpath = l[9:]
        hpath = wstring.chop(hpath)
        hpath = lexer.removecomment(hpath)
        hpath = wstring.strip(hpath)
        if hpath[-1] == ";":
            hpath = hpath[:-1]
        if len(hpath) < 3:
            continue  # minimum is: "a"
        if lexer.isheader(hpath):  # Has the format "name" or <name>
            add(hpath, filedir)
    # End for
    return
コード例 #2
0
ファイル: mover.py プロジェクト: stukemanmini/ECE_Material
def cprocess(name, filedir):
    if name is None:
        return

    name = decrease(name, filedir)
    print "processing", name

    f = open(name, "r")
    lines = f.readlines()
    f.close()

    if not lines:
        return

    for l in lines:
        if len(l) < 12:
            continue  # minimum length 12, ex: #include "a"
        if l[0] != "#":
            continue  # not a directive, pass
        if l[:9] != "#include ":
            continue  # not an include statement, pass
        hpath = l[8:]  # remove the '#include' string
        hpath = wstring.chop(hpath)  # remove separators
        hpath = lexer.removecomment(hpath)  # remove comments
        hpath = wstring.strip(hpath)  # remove extra whitespaces
        if hpath[-1] == ";":
            hpath = hpath[:-1]  # ignore useless delimiter
        if len(hpath) < 3:
            continue  # minimum is: "a"
        if lexer.isheader(hpath):  # test the format
            cfile = addc(hpath, filedir)  # add to the list of headers
            cprocess(cfile, filedir)
    # End for
    return
コード例 #3
0
ファイル: allhead.py プロジェクト: 2Habibie/ctocpp
def processfile(name):

  print "processing", name

  f = open(name, 'r')
  lines = f.readlines()
  f.close()
  if not lines: return

  for l in lines:
   if len(l) < 10: continue
   if l[0] != '#': continue
   if l[:9] != "#include ": continue
   hpath = l[9:]
   hpath = wstring.chop(hpath)
   hpath = lexer.removecomment(hpath)
   hpath = wstring.strip(hpath)
   if hpath[-1] == ';': hpath = hpath[:-1]
   if len(hpath) < 3: continue     # minimum is: "a"
   if lexer.isheader(hpath):       # Has the format "name"
       if not os.path.exists(hpath):
           hpath = hpath[1:-1]    # Removing double quotes	   
           hpath = "\\" + os.path.join(os.path.dirname(name), hpath)    # Add relative path of current file
       add(hpath)
  # End for
  return