示例#1
0
文件: View.py 项目: hihihippp/spyre
    def getJS(self):
        self.JS = ""
        for file in os.listdir(self.JS_PATH):
            if file.find('.js') > 0:
                file_path = self.JS_PATH + file
                print file_path
                f = codecs.open(file_path)
                content = f.read()
                self.JS += content.decode('utf-8')
                f = codecs.StreamReader(file_path)

                self.JS += "\n"
        return self.JS
示例#2
0
x['SetIteratorType'] = iter(_set)  #XXX: empty vs non-empty
# built-in types (CH 5)
if PY3:
    x['DictionaryItemIteratorType'] = iter(type.__dict__.items())
    x['DictionaryKeyIteratorType'] = iter(type.__dict__.keys())
    x['DictionaryValueIteratorType'] = iter(type.__dict__.values())
else:
    x['DictionaryItemIteratorType'] = type.__dict__.iteritems()
    x['DictionaryKeyIteratorType'] = type.__dict__.iterkeys()
    x['DictionaryValueIteratorType'] = type.__dict__.itervalues()
# string services (CH 7)
x['StructType'] = struct.Struct('c')
x['CallableIteratorType'] = _srepattern.finditer('')
x['SREMatchType'] = _srepattern.match('')
x['SREScannerType'] = _srepattern.scanner('')
x['StreamReader'] = codecs.StreamReader(_cstrI)  #XXX: ... and etc
# python object persistence (CH 11)
# x['DbShelveType'] = shelve.open('foo','n')#,protocol=2) #XXX: delete foo
if HAS_ALL:
    x['DbmType'] = dbm.open(_tempfile, 'n')
# x['DbCursorType'] = _dbcursor = anydbm.open('foo','n') #XXX: delete foo
# x['DbType'] = _dbcursor.db
# data compression and archiving (CH 12)
x['ZlibCompressType'] = zlib.compressobj()
x['ZlibDecompressType'] = zlib.decompressobj()
# file formats (CH 13)
x['CSVReaderType'] = csv.reader(_cstrI)
x['CSVWriterType'] = csv.writer(_cstrO)
x['CSVDictReaderType'] = csv.DictReader(_cstrI)
x['CSVDictWriterType'] = csv.DictWriter(_cstrO, {})
# cryptographic services (CH 14)
示例#3
0
        if lines[linenum].endswith('\r'):
            lines[linenum] = lines[linenum].rstrip('\r')

    lines = (['// marker so line numbers and indices both start at 1'] +
             lines + ['// marker so line numbers end in a known way'])
    return lines


if __name__ == '__main__':
    filenames = ParseArguments(sys.argv[1:])
    cpplint.Error = Error
    backup_err = sys.stderr
    try:
        # Change stderr to write with replacement characters so we don't die
        # if we try to print something containing non-ASCII characters.
        sys.stderr = codecs.StreamReader(sys.stderr, 'replace')
        cpplint._cpplint_state.ResetErrorCounts()
        for filename in filenames:
            cpplint.ProcessFile(filename, cpplint._cpplint_state.verbose_level)
            for rule in thirdRuleSet:
                third_checker = imp.load_source("", rule)
                tempfilename = os.path.split(rule)[1]
                rule_file_name = os.path.splitext(tempfilename)[0]
                str_list = rule_file_name.split('_', 1)
                rule_name = '/'.join(str_list)
                option_info = []
                if rule_name in checkers_options:
                    option_info = checkers_options[rule_name]
                currFilePath = filename
                plugin_clean_lines = cpplint.CleansedLines(
                    get_lines_for_filename(filename))