Пример #1
0
    def __init__(self, spec=None):
        '''
		Init L{SpecTokenList}
		@param spec: file or string to be parsed
		@type spec: string/file
		@return: None
		@rtype: None
		'''
        self.current = 0
        self.pointer = 0
        self.token_list = []

        # TODO: pass spec in another method
        if spec is None:
            return

        line = 1
        specFile = SpecFile(spec)
        while True:
            t = SpecToken(specFile)
            self.token_list.append(t)

            line += t.eol_count_prepend
            t.line = line
            line += t.eol_count_append

            if t.token == None:
                break
Пример #2
0
	def create(cls, parent, name, value):
		'''
		Create a definition
		@param parent: parent section
		@type parent: L{SpecSection}
		@param name: name of the definition
		@type name: string
		@param value: value of the definition
		@type value: string
		@return: newly created definition
		@rtype: L{SpecStDefinition}
		'''
		ret = SpecDefinitionEditor.obj(parent)
		ret.set_name(SpecToken.create(name))
		ret.set_value(SpecToken.create(value, append="\n"))
		return ret
Пример #3
0
    def create(cls, parent, name, value):
        '''
		Create a definition
		@param parent: parent section
		@type parent: L{SpecSection}
		@param name: name of the definition
		@type name: string
		@param value: value of the definition
		@type value: string
		@return: newly created definition
		@rtype: L{SpecStDefinition}
		'''
        ret = SpecDefinitionEditor.obj(parent)
        ret.set_name(SpecToken.create(name))
        ret.set_value(SpecToken.create(value, append="\n"))
        return ret
Пример #4
0
    def create(cls, parent, pkg=None):
        '''
		Create a package section
		@param parent: parent section
		@type parent: L{SpecSection}
		@param pkg: package name, None or '-' if main package
		@type pkg: string
		@return: newly created package section
		@rtype: L{SpecStPackage}
		'''
        ret = SpecStPackage(parent)
        pkg = None if pkg == None or pkg == '-' else pkg
        if pkg is not None:
            ret.set_package(SpecToken().create(pkg, append='\n'))
        ret.set_token_section(SpecToken().create(
            '%package', append='\n' if pkg is None else ' '))
        return ret
Пример #5
0
	def add_entry(cls, changelog, date, username, email, version, msg):
		'''
		Add a changelog entry to provided changelog
		@param changelog: a changelog section to be used
		@type changelog: L{SpecStChangelog}
		@param date: date used in entry
		@type date: datetime
		@param username: user name
		@type username: string
		@param email: email
		@type email: string
		@param version: version, if None, last version is used
		@type version: string
		@param msg: a message to be placed to the changelog entry
		@type msg: string
		@return: newly added entry
		@rtype: L{SpecStChangelog.SpecStChangelogEntry}
		'''
		entry = SpecChangelogEditor.obj.SpecStChangelogEntry(changelog)
		entry.set_star(SpecToken.create('*'))
		entry.set_date(SpecToken.create(date.strftime("%a %b %d %Y")))
		entry.set_date_parsed(date)
		entry.set_user(SpecToken.create(username))
		entry.set_user_email(SpecToken.create('<' + email + '>'))
		entry.set_version_delim(SpecToken.create('-'))
		if version is None:
			entry.set_version(changelog.get_entries()[0].get_version())
		else:
			entry.set_version(SpecToken.create(version, append = '\n'))
		entry.set_message(SpecToken.create(msg, append = '\n'))
		changelog.insert_entry(entry)

		return entry
Пример #6
0
    def add_entry(cls, changelog, date, username, email, version, msg):
        '''
		Add a changelog entry to provided changelog
		@param changelog: a changelog section to be used
		@type changelog: L{SpecStChangelog}
		@param date: date used in entry
		@type date: datetime
		@param username: user name
		@type username: string
		@param email: email
		@type email: string
		@param version: version, if None, last version is used
		@type version: string
		@param msg: a message to be placed to the changelog entry
		@type msg: string
		@return: newly added entry
		@rtype: L{SpecStChangelog.SpecStChangelogEntry}
		'''
        entry = SpecChangelogEditor.obj.SpecStChangelogEntry(changelog)
        entry.set_star(SpecToken.create('*'))
        entry.set_date(SpecToken.create(date.strftime("%a %b %d %Y")))
        entry.set_date_parsed(date)
        entry.set_user(SpecToken.create(username))
        entry.set_user_email(SpecToken.create('<' + email + '>'))
        entry.set_version_delim(SpecToken.create('-'))
        if version is None:
            entry.set_version(changelog.get_entries()[0].get_version())
        else:
            entry.set_version(SpecToken.create(version, append='\n'))
        entry.set_message(SpecToken.create(msg, append='\n'))
        changelog.insert_entry(entry)

        return entry