当前位置: 首页>>代码示例>>Python>>正文


Python transformer.TX类代码示例

本文整理汇总了Python中xierpa3.toolbox.transformer.TX的典型用法代码示例。如果您正苦于以下问题:Python TX类的具体用法?Python TX怎么用?Python TX使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了TX类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _get_expression

 def _get_expression(self):
     expressions = []
     if self.min:
         expressions.append('(min-width:%s)' % TX.px(self.min))
     if self.max:
         expressions.append('(max-width:%s)' % TX.px(self.max))
     if self.device or expressions:
         return (self.device or 'all') + ' and ' + ' and '.join(expressions)
     return None # Raising error, style as media needs a defined expression
开发者ID:simons-design,项目名称:Xierpa3,代码行数:9,代码来源:style.py

示例2: buildResource

 def buildResource(self, site):
     u"""The url refers to a xierpa3 resource, try to find it and answer the result
     with the appropriate mime type."""
     path = TX.path2ParentDirectory(TX.module2Path(xierpa3)) + site.e.request.path
     if os.path.exists(path):
         f = open(path, 'rb')
         result = f.read()
         f.close()
         return result, self.C.MIMETYPE_PNG
     return '', self.C.MIMETYPE_HTML
开发者ID:petrvanblokland,项目名称:Xierpa3,代码行数:10,代码来源:baseclient.py

示例3: updateArticle

 def updateArticle(self, id, path):
     u"""Update the article from *id* and *path*. Set the modification time, so we know
     when the file is updated."""
     data = None
     wiki = self.readWikiFile(path)
     if wiki is not None:
         data = self.compileArticle(wiki)
         data.id = id
         data.source = wiki
         data.ranking = TX.asInt(data.ranking) or 0 # Make sure we can sort on the ranking field.
         data.blogresponse = TX.asBool(data.blogresponse) 
         data.path = path # Keep the source path is case POST needs to save to the file.
         data.modificationTime = os.path.getmtime(path) # @@@ TODO: Should be DateTime instance.
         self.cacheArticle(data)
     return data
开发者ID:thongnv,项目名称:Xierpa3,代码行数:15,代码来源:textilefileadapter.py

示例4: getColClass

 def getColClass(self, col):
     u"""Answer the colClass, based on the numeric <i>col</i> value and if the component is the
     last in the parent list of child components."""
     colClass = TX.col2Class(col)
     if self.parent.isLast(self):
         colClass = (colClass, C.CLASS_LAST)
     return colClass
开发者ID:simons-design,项目名称:Xierpa3,代码行数:7,代码来源:component.py

示例5: baseComponents

 def baseComponents(self):
     u"""Create the component instances"""
     # Import current example site, as anchor for the article files.
     from xierpa3.sites.examples import textilearticles
     # Root path where to find the article Simples wiki file for this example page.
     articleRoot = TX.module2Path(textilearticles) + '/files/articles/' 
     adapter = ArticleAdapter(articleRoot) # Preferred adapter class for articles in this site.
     # Create navigation instance, to choose between the available articles.
     menu = Menu(adapter=adapter)
     menuContainer = Container(components=menu)
     # Create the article component to contain articles answered by the adapter.
     #article = SimplexArticle(adapter=adapter) 
     article = Article(width=Perc(70), adapter=adapter, showPoster=True, splitChapters=False) 
     articleSideBar = ArticleSideBar(width=Perc(22), adapter=adapter)
     featuredArticles = FeaturedByImage(width=Perc(22), adapter=adapter, 
         # Example to overwrite the default BluePrint parameter titleColor                               
         titleColor=Color('red'))
     #featuredByImage = FeaturedByText(widht=Perc(22), adapter=adapter)
     # Make main page container for the article column
     container = Container(components=(
         #article,
         articleSideBar,
         #featuredArticles,
         #featuredByImage
     )) 
     # The class is also the page name in the url.
     homePage = Page(class_=self.C.TEMPLATE_INDEX, name=self.C.TEMPLATE_INDEX, 
         fonts=self.URL_FONTS, title=self.TITLE, css=self.C.URL_CSS, 
         components=(menuContainer, container))
     return [homePage]
开发者ID:petrvanblokland,项目名称:Xierpa3,代码行数:30,代码来源:make.py

示例6: write_attribute

 def write_attribute(self, key, value):
     u"""
     Auxiliary function to write each attribute to @[email protected] If the *key* is defined in
     @[email protected] then only output the single key name (even if this breaks XML
     validation). By default the @[email protected] is empty, but it can be redefined by the
     inheriting application class.
     If the *key* is in @[email protected] and the *value* is tuple or
     a list, then join the *value*, separated by spaces. This feature is especially used to build flexible
     cascading *class_* attributes.
     If the attribute has no value, then the output is skipped.
     """
     line = None
     if key == 'class_':
         key = 'class'
         value = self.class2SpaceString(value)
     if key in self.SINGLE_ATTRIBUTES:
         line = u' ' + key
     elif isinstance(value, (list, tuple)):
         if key in self.CASCADING_ATTRIBUTES:
             value = TX.flatten2Class(value)
             if isinstance(value, basestring):
                 value = value.replace('"', '&quot;');
             if value:
                 line = u' %s="%s"' % (key, value)
         else:
             raise ValueError('[XmlTagBuilder.write_attribute] No list attribute value allowed for %s="%s"' % (key, `value`))
     elif value:
         if isinstance(value, basestring):
             value = value.replace('"', '&quot;');
         line = u' %s="%s"' % (key, value)
     if line:
         self.output(line)
开发者ID:thongnv,项目名称:Xierpa3,代码行数:32,代码来源:xmltagbuilderpart.py

示例7: script

 def script(self, charset='UTF-8', type='text/javascript', **args):
     """
     The <code>br</code> tag inserts a single line break.<br/>
     Defines a script, such as a JavaScript. Note that if @src is used, then no <code>self._script()</code> must be used.
     The count attribute is not standard XHTML. It indicates the number of <code>br</code> to repeat.<br/>
     <seealso><www href="http://www.w3schools.com/tags/tag_script.asp" target="external"/></seealso>
     <python>
     self.script()<br/>
     ...<br/>
     self._script()
     </python>
     """
     #
     #     Build script. Note that if @src is used, then no self._script()
     #     must be used.
     #
     r = self.result.peek()
     r.write(u'<script')
     # Make sure to write "UTF-8" instead of "utf-8" since FireFox 2.0.0.4 will
     # ignore the script otherwise.
     r.write(u' charset="%s"' % charset.upper())
     r.write(u' type="%s"' % type)
     language = args.get(u'language')
     if language is not None:
         r.write(u' language="%s"' % language)
     for key, value in args.items():
         r.write(u' %s="%s"' % (TX.dataAttribute2Html5Attribute(key), value))
     src = args.get(u'src')
     if src is not None:
         r.write(u'></script>\n')
     else:
         self._pushTag(u'script')
         r.write(u'>\n')
开发者ID:thongnv,项目名称:Xierpa3,代码行数:33,代码来源:htmlbuilderpart.py

示例8: makeDirectory

 def makeDirectory(self, path):
     u"""Make sure that the directory of path (as file) exists. Otherwise create it.
     Answer the directory path for convenience of the caller."""
     dirPath = TX.path2Dir(path)
     if not os.path.exists(dirPath):
         os.makedirs(dirPath)
     return dirPath
开发者ID:petrvanblokland,项目名称:Xierpa3,代码行数:7,代码来源:builder.py

示例9: baseComponents

    def baseComponents(self):        
        # Import current example site, as anchor for the article files.
        from xierpa3.sites import doingbydesign
        # Root path where to find the article Simples wiki file for this example page.
        articleRoot = TX.module2Path(doingbydesign) + '/files/articles/'
        adapter = DbDAdapter(articleRoot) # Preferred adapter class for articles in this site.

        logo = Logo(text='Doing by Design', fontFamily='Impact', color=Color('#888'), fontSize=Em(1.8))
        menu = Menu()
        mobileNavigation = DbDMobileNavigation()
        article = Article()

        featuredByImage = FeaturedByImage(start=0, width=Perc(65.4), showTitle=False,
            showHeadline=False, showTopic=False)
        featuredByText = FeaturedByText(start=0, width=Perc(30.75))

        # Containers
        top = Top(components=(logo, menu), media=Media(max=self.C.M_MOBILE_MAX, display=self.C.NONE))
        featured = Featured(components=(featuredByImage, featuredByText), backgroundColor=Color('#262c37'))
        section = Section(components=(featuredByImage,))
        mainContent = MainContent(components=article)
        footer = Footer(components=(menu))

        homePage = Page(name=self.C.TEMPLATE_INDEX,
            components=(mobileNavigation, top, featured, section, mainContent, footer),
            css=self.C.URL_CSS, fonts=self.C.URL_FONTS, js=self.URL_JAVASCRIPT,
            favicon=self.C.URL_FAVICON, adapter=adapter)

        articlePage = Page(name=self.C.TEMPLATE_ARTICLE,
            comoonents=(mobileNavigation, top, article, footer),
            css=self.C.URL_CSS, fonts=self.C.URL_FONTS, js=self.URL_JAVASCRIPT,
            favicon=self.C.URL_FAVICON, adapter=adapter)

        return [homePage, articlePage]
开发者ID:petrvanblokland,项目名称:Xierpa3,代码行数:34,代码来源:doingbydesign.py

示例10: baseComponents

    def baseComponents(self):
        # Create the article adapter
        # Import articles from the doingbydesign site, sharing the article files.
        from xierpa3.sites import doingbydesign
        # Root path where to find the article Simplex wiki file for this example page.
        articleRoot = TX.module2Path(doingbydesign) + '/files/articles/'
        adapter = SimpleSiteAdapter(articleRoot)

        # Header
        logo = Logo()
        menu = Menu()
        header = Header(components=(logo,menu), mobileContainerDisplay=self.C.NONE,
            doc_mobileContainerDisplay=u'Header is not visible for mobile')
        mobileNavigation = MobileNavigation() # Is container by itself. Change??

        # Create the component instances
        article = Article(width=Perc(68))
        featuredByImage = FeaturedByImage(count=1, width=Perc(30))
        featuredByText = FeaturedByText(start=1, count=3, width=Perc(30))
        # Create the single page instance, containing the number of components
        mainHome = Container(components=(article, featuredByImage, featuredByText))

        # Footer
        footer = Footer(components=(menu,), containerBackgroundColor=self.FOOTERBGCOLOR)

        # The class is also the page name in the url.
        homePage = Page(class_=self.C.TEMPLATE_INDEX, name=self.C.TEMPLATE_INDEX, adapter=adapter,
            #components=(mobileNavigation, header, mainHome, footer),
            #components=(header, mainHome, footer),
            components=Container(header),
            fonts=self.URL_FONTS, title=self.TITLE, css=self.C.URL_CSS)
        return [homePage]
开发者ID:thongnv,项目名称:Xierpa3,代码行数:32,代码来源:make.py

示例11: make

 def make(self, root=None):
     u"""The instance of this class builds CSS and HTML files at the optional path *root*.
     If not defined, then @[email protected] is used, as in general builders 
     are associated where output should go to. 
     E.g. the default @[email protected] is defined as to the user extended 
     path of @~/Desktop/Xierpa3Examples/[component.name]@.
     And for @[email protected] it is @~/Desktop/Xierpa3Examples/[component.name]/css/[email protected]"""
     if root is None:
         root = TX.asDir(self.C.PATH_EXAMPLES) # Expand user path to full directory path.
     # C S S
     # Create the main CSS builder instance to build the CSS part of the site.
     cssBuilder = CssBuilder()
     # Compile (=build) the SCSS to CSS.
     self.build(cssBuilder) 
     # Save the file in "css/style.css".
     cssBuilder.save(self, root=root) 
 
     # H T M L
     # Create the main HTML builder instance to build the HTML part of the site.
     htmlBuilder = HtmlBuilder()
     # Compile the site instance and its components into HTML code.
     self.build(htmlBuilder) 
     # Save the resulting HTML file in "helloWorld.html"
     # Answer the file path, so we can directly open the file with a browser.
     return htmlBuilder.save(self, root=root)  
开发者ID:petrvanblokland,项目名称:Xierpa3,代码行数:25,代码来源:make.py

示例12: buildBlock

 def buildBlock(self, b):
     colClass = TX.col2Class('graph')
     s = self.style
     b.block(self)
     b.div(class_=colClass, float=s.graphFloat or self.LEFT, width=s.graphWidth or Perc(100))
     b._div(comment=colClass)
     b._block(self)
开发者ID:petrvanblokland,项目名称:Xierpa3,代码行数:7,代码来源:graph.py

示例13: image

 def image(self, component, class_=None):
     u"""
     """
     if component.style:
         width = component.style.width_html # Take explicit HTML width/height if defined in component.
         height = component.style.height_html
     else:
         width = None
         height = None
     if height is None and width is None:
         width = '100%'
     elif height is not None:
         width = None
     alt = component.alt or TX.path2Name(component.url)
     self.img(src=component.url, width_html=width, height_html=height, alt=alt,
         class_=TX.flatten2Class(class_, component.getPrefixClass()))
开发者ID:thongnv,项目名称:Xierpa3,代码行数:16,代码来源:htmlbuilder.py

示例14: getFilePath

 def getFilePath(self, site):
     u"""
     Answers the file path, based on the URL. Add '/files' to hide Python sources from view.
     The right 2 slash-parts of the site path are taken for the output (@@@ for now)
     """
     if site.e is not None:
         return TX.class2Path(site) + "/files/" + "/".join(site.e.path.split("/")[-2:])
     return None
开发者ID:simons-design,项目名称:Xierpa3,代码行数:8,代码来源:baseclient.py

示例15: __init__

    def __init__(self, col, format="hex", bw=None, bwrgb=None):

        self.alpha = 1
        self.bwlevel = bw or BWLEVEL
        self.bwrgb = bwrgb or BWRGBWEIGHT

        if isinstance(col, (long, float, int)):
            col = hex(col)
        elif isinstance(col, Color):
            col = col.hex
        if format in ('cmyk', 'rgb', 'hex', 'uhex'):
            self.format = format
        else:
            raise ValueError('[Color] Wrong format "%s". Should be in %s' % (format, repr(('cmyk', 'rgb', 'hex', 'uhex'))))
        try:
            if isinstance(col, basestring):
                # Convert unreliable HTML/CSS color name to hex value and process from there.
                col = COLOR_NAMES.get(col, col)

                if ',' in col:
                    self.c = TX.list2IntFloatList(col)
                elif HEXTUPLE.match(col):
                    if len(col) == 4:
                        col = '#%s%s%s' % (col[1]*2, col[2]*2, col[3]*2)
                    self.c = col
                elif UHEXTUPLE.match(col):
                    col = col[2:]
                    if len(col) == 4:
                        col = '#%s%s%s' % (col[1]*2, col[2]*2, col[3]*2)
                    self.c = col
                elif RGBTUPLE.match(col):
                    mrgb = RGBTUPLE.match(col)
                    self.c = (int(mrgb.group(1)), int(mrgb.group(2)), int(mrgb.group(3)))
                elif RGBATUPLE.match(col):
                    mrgb = RGBTUPLE.match(col)
                    self.c = (int(mrgb.group(1)), int(mrgb.group(2)), int(mrgb.group(3)))
                    self.alpha = float(mrgb.group(4))
                elif CMYKTUPLE.match(col):
                    mcmyk = CMYKTUPLE.match(col)
                    self.c = (int(mcmyk.group(1)), int(mcmyk.group(2)), int(mcmyk.group(3)), int(mcmyk.group(4)))
                else:
                    ValueError('[Color] Unknown color format "%s"' % color)
            else:
                self.c = col
                if len(self.c) == 3 and sum(self.c) <= 3:
                    # Test for 0-1 values - RGB values should be 0-255
                    self.c = list(self.c)
                    for i in range(3):
                        if self.c[i] <= 1 and self.c[i] / 2 == float(self.c[i]) / 2:
                            self.c[i] *= 255
                            self.c[i] = int(self.c[i])
                    self.c = tuple(self.c)
        except:
            raise ValueError('[Color] Wrong color format "%s"' % color)

        rgbint = color.rgb(self.c)
        self.r, self.g, self.b = color._int2rgbtuple(rgbint)
        self.h, self.l, self.s = _rgb2hls(self.r, self.g, self.b)
开发者ID:thongnv,项目名称:Xierpa3,代码行数:58,代码来源:coloring.py


注:本文中的xierpa3.toolbox.transformer.TX类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。