def testSimpleGeneralObjectParser(self):
     generalObjectParser = GeneralObjectParser(
                 field1 = Field(int, 5),
                 field2 = Field(str, 'mydefaultvalue'),
             )
     generalObjectParser.field1.parsedValue += "31"
     obj = generalObjectParser.generateResultObject()
     self.assertEquals(31, obj.field1)
     self.assertEquals('mydefaultvalue', obj.field2)
 def testErroneousGeneralObjectParser(self):
     generalObjectParser = GeneralObjectParser(
                 field1 = Field(int, 5),
                 field2 = Field(str, 'mydefaultvalue'),
             )
     generalObjectParser._VERBOSE = False
     generalObjectParser.field1.parsedValue += "this.is.not.an.int"
     obj = generalObjectParser.generateResultObject()
     self.assertEquals(5, obj.field1)
     self.assertEquals('mydefaultvalue', obj.field2)
Esempio n. 3
0
def generateFeed():
    """
    generateGeneralConfigObject() -> GeneralObjectParser object
    
    Creates a new GeneralObjectParser with the fields found in the configuration
    on each <feed> tag.
    
    Fields:
    - url: string with the url
    - name: string of the author of the blog
    - face: string with the relative path to the image used for representing the 
      user. This path is relative to the output directory.
    - faceWidth:  horizontal size of the face image
    - faceHeight: vertical size of the face image
    """
    return GeneralObjectParser(
        url=Field(str, DEFAULT_URL),
        name=Field(str, DEFAULT_NAME),
        face=Field(str, DEFAULT_FACE),
        faceWidth=Field(str, DEFAULT_FACE_HEIGHT),
        faceHeight=Field(str, DEFAULT_FACE_WIDTH),
    )
Esempio n. 4
0
def generateGeneralConfigObject():
    """
    generateGeneralConfigObject() -> GeneralObjectParser object
    
    Creates a new GeneralObjectParser with the fields found in the configuration
    under the <general> tag.
    
    Fields:
    - name: string with the name of the planet
    - link: string with the full link to the planet
    - rssTemplateName: string with the relative path of the RSS template. This path 
       is relative to the current directory.
    - htmlTemplateName: string with the relative path of the HTML template. This path
       is relative to the current directory.
    - rssFileName: string with the relative path of the generated RSS file. This path
       is relative to the current directory.
    - htmlFileName: string with the relative path of the generated HTML file. This path
       is relative to the current directory.
    - maxPostNumber: integer with the max number of posts listed in the planet
    - generator: string with the name of the generator
    - feedType: string with the type of the feed (rss, for example)
    - rssRelativePath: string with the relative path of the generated RSS file. This path
       is relative to the HTML file
    """
    return GeneralObjectParser(
        name=Field(str, 'Default name'),
        link=Field(str, 'http://default.link/'),
        rssTemplateName=Field(str, 'rss20.xml.tmpl'),
        htmlTemplateName=Field(str, 'index.xml.tmpl'),
        rssFileName=Field(str, 'output%srss20.xml' % os.sep),
        htmlFileName=Field(str, 'output%sindex.html' % os.sep),
        maxPostNumber=Field(int, 10),
        generator=Field(str, 'KamPlanet 0.2'),
        feedType=Field(str, 'rss'),
        rssRelativePath=Field(str, 'rss20.xml'),
    )