Changeset 3686

Show
Ignore:
Timestamp:
03/12/08 16:16:48 (5 weeks ago)
Author:
dmeyer
Message:

cosmetic changes

Location:
trunk/base
Files:
25 modified

Legend:

Unmodified
Added
Removed
  • trunk/base/TODO

    r3684 r3686  
    1212- Rewrite of Process class 
    1313- Complete documentation 
    14  
     14- Adjust kaa.distribution to not import anything from kaa itself. Right now 
     15  svn2log.py imports kaa.xmlutils 
    1516 
    1617TODO either before or after 1.0: 
  • trunk/base/src/config.py

    r2950 r3686  
    243243                    else: 
    244244                        allowed = ', '.join([ str(x) for x in self._type ]) 
    245                     allowed = textwrap.wrap(allowed, 78,  
     245                    allowed = textwrap.wrap(allowed, 78, 
    246246                                          initial_indent = '# | Allowed values: ', 
    247247                                          subsequent_indent = '# |' + 17 * ' ') 
     
    450450        return self._vars.__iter__() 
    451451 
    452      
     452 
    453453class Dict(Base): 
    454454    """ 
     
    470470            var = self._cfg_get(key) 
    471471            var._default = var._value = value 
    472              
     472 
    473473 
    474474 
     
    540540            ret.append(cfgstr) 
    541541            if space_vars: 
    542                 # Separate multi-line subgroups with newline.  
     542                # Separate multi-line subgroups with newline. 
    543543                ret.append('') 
    544544 
     
    741741        """ 
    742742        local_encoding = get_encoding() 
    743         if filename:  
     743        if filename: 
    744744            filename = os.path.expanduser(filename) 
    745745        if not filename: 
     
    885885            except SystemError: 
    886886                pass 
    887              
     887 
    888888        assert(self._filename) 
    889889        if self._watch_mtime == 0: 
     
    956956    if isinstance(var, VarProxy): 
    957957        return var._item._default 
    958      
     958 
    959959 
    960960def get_description(var): 
     
    975975        return var._item._type 
    976976    return type(var) 
    977      
     977 
    978978 
    979979def get_config(filename, module = None): 
     
    982982    'filenane'.  If module is None, the specified config file must have the 
    983983    module specified (in the "-*- module: ... -*-" metadata), otherwise the 
    984     supplied module (string) is used.  The module must be importable.   
    985      
     984    supplied module (string) is used.  The module must be importable. 
     985 
    986986    If the config module cannot be determined and one is not specified, 
    987987    will raise ValueError.  If import fails, will raise ImportError. 
  • trunk/base/src/db.py

    r3355 r3686  
    135135    fname_noext, ext = os.path.splitext(filename) 
    136136    levels = dirname.strip('/').split(os.path.sep)[2:][-2:] 
    137     return PATH_SPLIT.split(' '.join(levels + [fname_noext]))  
     137    return PATH_SPLIT.split(' '.join(levels + [fname_noext])) 
    138138 
    139139 
     
    217217        self.last_item = None 
    218218        self.last_expr = None 
    219          
     219 
    220220    def __call__(self, expr, item): 
    221221        if item is None: 
     
    358358        Note: currently indexes and attributes can only be added, not removed. 
    359359        That is, once an attribute or indexes is added, it lives forever. 
    360          
     360 
    361361        type_name is the name of the type the attributes and indexes apply to 
    362         (e.g. 'dir' or 'image').  
     362        (e.g. 'dir' or 'image'). 
    363363 
    364364        indexes is a list of tuples, where each tuple contains 2 or more strings, 
     
    444444                   raise ValueError, "Unsupported attempt to convert attribute '%s' " \ 
    445445                                     "between ATTR_SIMPLE and ATTR_SEARCHABLE" % attr_name 
    446                      
     446 
    447447                if attr_name not in cur_type_attrs or cur_type_attrs[attr_name] != attr_defn: 
    448                     # There is a new attribute specified for this type, or an  
     448                    # There is a new attribute specified for this type, or an 
    449449                    # existing one has changed. 
    450450                    new_attrs[attr_name] = attr_defn 
     
    543543 
    544544        if new_attrs: 
    545             # Migrate rows from old table to new temporary one.  Here we copy only  
     545            # Migrate rows from old table to new temporary one.  Here we copy only 
    546546            # ATTR_SEARCHABLE columns that exist in both old and new definitions. 
    547547            columns = filter(lambda x: cur_type_attrs[x][1] & ATTR_SEARCHABLE and \ 
     
    557557        self._db_query('ALTER TABLE %s_tmp RENAME TO %s' % (table_name, table_name)) 
    558558 
    559         # Create a trigger that reduces the objectcount for each applicable  
     559        # Create a trigger that reduces the objectcount for each applicable 
    560560        # inverted index when a row is deleted. 
    561561        inverted_indexes = self._get_type_inverted_indexes(type_name) 
     
    594594        terms of length smaller than min or larger than max will not be 
    595595        indexed.  If neither is specified, terms of all sizes will be indexed. 
    596          
     596 
    597597        split is either a callable or a regular expression (or a string in 
    598598        which case it is compiled as a regexp) and is used to parse 
     
    616616 
    617617        if split is None: 
    618             # Default split regexp is to split words on  
     618            # Default split regexp is to split words on 
    619619            # alphanumeric/digits/underscore boundaries. 
    620620            split = re.compile("[\W_\d]+", re.U) 
     
    640640        } 
    641641 
    642         self._db_query("INSERT OR REPLACE INTO inverted_indexes VALUES(?, 'definition', ?)",  
     642        self._db_query("INSERT OR REPLACE INTO inverted_indexes VALUES(?, 'definition', ?)", 
    643643                       (name, buffer(cPickle.dumps(defn, 2)))) 
    644644 
    645645        defn['objectcount'] = 0 
    646646        self._inverted_indexes[name] = defn 
    647          
     647 
    648648 
    649649    def _load_inverted_indexes(self): 
     
    841841                           _list_to_printable(inverted_indexes)) 
    842842 
    843          
     843 
    844844        # Process inverted index maps for this row 
    845845        ivtidx_terms = [] 
     
    922922                # Simple attribute needs pickle 
    923923                get_pickle = True 
    924          
     924 
    925925        # TODO: if ObjectRow is supplied, don't need to fetch columns 
    926926        # that are available in the ObjectRow.  (Of course this assumes 
     
    11311131                    raise ValueError, "One or more requested attributes %s are not available for type '%s'" % \ 
    11321132                                      (str(missing), type_name) 
    1133                 # If any of the requested attributes are ATTR_SIMPLE or  
     1133                # If any of the requested attributes are ATTR_SIMPLE or 
    11341134                # ATTR_INDEXED_IGNORE_CASE then we need the pickle. 
    1135                 pickled = [ x for x in columns if type_attrs[x][1] & (ATTR_SIMPLE | ATTR_INDEXED_IGNORE_CASE) in  
     1135                pickled = [ x for x in columns if type_attrs[x][1] & (ATTR_SIMPLE | ATTR_INDEXED_IGNORE_CASE) in 
    11361136                                                                     (ATTR_SIMPLE, ATTR_INDEXED_IGNORE_CASE)] 
    11371137                if pickled: 
     
    11401140                    if 'pickle' not in columns: 
    11411141                        columns.append('pickle') 
    1142                     # Remove the list of pickled attributes so we don't  
     1142                    # Remove the list of pickled attributes so we don't 
    11431143                    # request them as sql columns. 
    11441144                    columns = list(set(columns).difference(pickled)) 
     
    11471147 
    11481148            # Now construct a query based on the supplied attributes for this 
    1149             # object type.   
    1150              
     1149            # object type. 
     1150 
    11511151            # If any of the attribute names aren't valid for this type, then we 
    11521152            # don't bother matching, since this an AND query and there won't be 
     
    12381238 
    12391239        # If ivtidx search was done, sort results based on score (highest 
    1240         # score first).  
     1240        # score first). 
    12411241        if ivtidx_results: 
    12421242            results.sort(lambda a, b: cmp(ivtidx_results[(b[1], b[2])], ivtidx_results[(a[1], a[2])])) 
     
    12541254        split terms (only used if a string is given for terms), and ivtidx is 
    12551255        the name of inverted index we're scoring for. 
    1256          
     1256 
    12571257        Terms are either unicode objects or strings, or sequences of unicode or 
    12581258        string objects.  In the case of strings, they are passed through 
     
    15541554                # end loop over terms 
    15551555 
    1556                  
     1556 
    15571557                for r in reduce(lambda a, b: set(a).intersection(b), results.values()): 
    15581558                    all_results[r] = 0 
     
    16111611 
    16121612        # end loop while not finished 
    1613         log.info('%d results, did %d subqueries, %.04f seconds (%.04f overhead)',  
     1613        log.info('%d results, did %d subqueries, %.04f seconds (%.04f overhead)', 
    16141614                 len(all_results), nqueries, time.time()-t0, t1-t0) 
    16151615        return all_results 
     
    16201620        Obtains terms for the given inverted index name.  If associated is 
    16211621        None, all terms for the inverted index are returned.  The return 
    1622         value is a list of 2-tuples, where each tuple is (term, count).  
     1622        value is a list of 2-tuples, where each tuple is (term, count). 
    16231623        Count is the total number of objects that term is mapped to. 
    16241624 
     
    16281628        count reflects the number of objects which have that term plus all 
    16291629        of the given associated terms. 
    1630          
     1630 
    16311631        For example, given an otherwise empty database, if you have an object 
    16321632        with terms ['vacation', 'hawaii'] and two other object with terms 
     
    16521652 
    16531653        if not associated: 
    1654             return self._db_query('''SELECT term, count  
     1654            return self._db_query('''SELECT term, count 
    16551655                                      FROM ivtidx_%s_terms AS terms 
    16561656                                        %s 
     
    16641664            return [] 
    16651665 
    1666         query = '''SELECT term, COUNT(*) AS total  
     1666        query = '''SELECT term, COUNT(*) AS total 
    16671667                     FROM ivtidx_%s_terms_map AS t0''' % ivtidx 
    16681668        for n, term_id in enumerate(term_ids): 
     
    16801680                 (ivtidx, _list_to_printable(term_ids), where_clause) 
    16811681        return self._db_query(query, where_values) 
    1682          
     1682 
    16831683 
    16841684    def get_db_info(self): 
  • trunk/base/src/distribution/build_py.py

    r2855 r3686  
     1# -*- coding: iso-8859-1 -*- 
     2# ----------------------------------------------------------------------------- 
     3# build_py.py - kaa.config cxml install support 
     4# ----------------------------------------------------------------------------- 
     5# $Id$ 
     6# 
     7# ----------------------------------------------------------------------------- 
     8# Copyright (C) 2006-2008 Dirk Meyer, Jason Tackaberry 
     9# 
     10# First Edition: Dirk Meyer <dmeyer@tzi.de> 
     11# Maintainer:    Dirk Meyer <dmeyer@tzi.de> 
     12# 
     13# Please see the file AUTHORS for a complete list of authors. 
     14# 
     15# This library is free software; you can redistribute it and/or modify 
     16# it under the terms of the GNU Lesser General Public License version 
     17# 2.1 as published by the Free Software Foundation. 
     18# 
     19# This library is distributed in the hope that it will be useful, but 
     20# WITHOUT ANY WARRANTY; without even the implied warranty of 
     21# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
     22# Lesser General Public License for more details. 
     23# 
     24# You should have received a copy of the GNU Lesser General Public 
     25# License along with this library; if not, write to the Free Software 
     26# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 
     27# 02110-1301 USA 
     28# 
     29# ----------------------------------------------------------------------------- 
     30 
     31# python imports 
    132import os 
    233import glob 
  • trunk/base/src/distribution/core.py

    r3685 r3686  
    66# 
    77# ----------------------------------------------------------------------------- 
    8 # Copyright (C) 2006 Dirk Meyer, Jason Tackaberry 
     8# Copyright (C) 2005-2008 Dirk Meyer, Jason Tackaberry 
    99# 
    1010# First Edition: Dirk Meyer <dmeyer@tzi.de> 
     
    133133        b = [ x.zfill(maxlen) for x in b.split('.') ] 
    134134        # TODO: special handling of rc and beta (others?) suffixes, so 
    135         # that 1.0.0 > 1.0.0rc1  
     135        # that 1.0.0 > 1.0.0rc1 
    136136        return cmp(a, b) 
    137137 
     
    345345        return os.path.exists(os.path.join(distutils.sysconfig.get_python_inc(), 'Python.h')) 
    346346 
    347          
     347 
    348348    def convert(self): 
    349349        """ 
     
    365365 
    366366        # Keep a reference to self in the distutils Extension object, so that 
    367         # after distutils.setup() is run, we can clean() the kaa Extension  
     367        # after distutils.setup() is run, we can clean() the kaa Extension 
    368368        # object. 
    369369        ext._kaa_ext = self 
     
    415415    user_options = [] 
    416416    docfiles = [] 
    417      
     417 
    418418    def initialize_options (self): 
    419419        pass 
    420      
     420 
    421421    def finalize_options (self): 
    422422        pass 
    423      
     423 
    424424    def run(self): 
    425425        self.run_command('build') 
     
    443443        else: 
    444444            python_dirname = prefix + dirname[3:].replace('/', '.') 
    445             # Anything under module/src/extensions/foo gets translated to  
     445            # Anything under module/src/extensions/foo gets translated to 
    446446            # kaa.module.foo. 
    447447            python_dirname = python_dirname.replace(".extensions.", ".") 
     
    472472    if 'plugins' in kwargs: 
    473473        del kwargs['plugins'] 
    474          
     474 
    475475    # convert Extensions 
    476476    if kwargs.get('ext_modules'): 
     
    505505                    break 
    506506            f.close() 
    507             
     507 
    508508    if len(sys.argv) > 1 and sys.argv[1] in ('bdist_rpm', 'sdist') and \ 
    509509           os.path.isfile('ChangeLog.in'): 
     
    518518            print 'generate doc' 
    519519            os.system('(cd doc; make clean; make html)') 
    520          
     520 
    521521    # delete 'module' information, not used by distutils.setup 
    522522    kwargs.pop('module', None) 
     
    558558    kwargs['cmdclass']['doc'] = Doc 
    559559    Doc.docfiles = kwargs.pop('epydoc', []) 
    560          
     560 
    561561    if len(sys.argv) > 1 and sys.argv[1] == 'bdist_rpm': 
    562562        dist = None 
     
    586586 
    587587        if 'rpminfo' in kwargs: 
    588             # Grab rpm metadata from setup kwargs and expose as cmdline  
     588            # Grab rpm metadata from setup kwargs and expose as cmdline 
    589589            # parameters to distutils. 
    590590            rpminfo = kwargs['rpminfo'] 
  • trunk/base/src/distribution/svn2log.py

    r3645 r3686  
    4040except ImportError: 
    4141    from kaa.xmlutils import SaxTreeHandler 
    42      
     42 
    4343class Entry(object): 
    4444    def __init__(self, author, date): 
     
    8080            writer.write('\n') 
    8181        writer.write('\n') 
    82          
     82 
    8383class LogParser(SaxTreeHandler): 
    8484 
     
    9090        self._user = user 
    9191        self._writer = writer 
    92          
     92 
    9393    def handle(self, node): 
    9494        revision = node.getattr('revision') 
     
    127127                        print path.content 
    128128                    print 
    129                      
     129 
    130130        if self._entry and (self._entry.author != author or self._entry.date != date): 
    131131            self._entry.write(self._writer) 
     
    153153    prefix.sort() 
    154154    prefix.reverse() 
    155      
     155 
    156156    # Create a parser 
    157157    parser = xml.sax.make_parser() 
  • trunk/base/src/distribution/version.py

    r2116 r3686  
    66# 
    77# ----------------------------------------------------------------------------- 
    8 # Copyright (C) 2005 Dirk Meyer, Jason Tackaberry 
     8# Copyright (C) 2005-2006 Dirk Meyer, Jason Tackaberry 
    99# 
    1010# First Edition: Dirk Meyer <dmeyer@tzi.de> 
  • trunk/base/src/distribution/xmlconfig.py

    r3645 r3686  
    66# 
    77# ----------------------------------------------------------------------------- 
    8 # Copyright (C) 2006 Dirk Meyer, Jason Tackaberry 
     8# Copyright (C) 2006-2008 Dirk Meyer, Jason Tackaberry 
    99# 
    1010# First Edition: Dirk Meyer <dmeyer@tzi.de> 
     
    8585        return schema 
    8686 
    87      
     87 
    8888    def parse(self, node, fd, deep=''): 
    8989        fd.write('%s(' % node.nodeName.capitalize()) 
     
    103103                fd.write('desc=\'%s\'' % desc) 
    104104        getattr(self, '_parse_%s' % node.nodeName.lower())(node, fd, deep, first) 
    105      
     105 
    106106 
    107107    def _parse_var(self, node, fd, deep, first): 
     
    127127        fd.write(')') 
    128128 
    129      
     129 
    130130    def _parse_config(self, node, fd, deep, first): 
    131131        self._parse_group(node, fd, deep, first) 
    132          
     132 
    133133 
    134134    def _parse_group(self, node, fd, deep, first): 
     
    145145            fd.write(", module='%s.config'" % self._package) 
    146146        fd.write(')') 
    147      
    148      
     147 
     148 
    149149    def _parse_list(self, node, fd, deep, first): 
    150150        if not first: 
     
    171171        if defaults: 
    172172            fd.write(', defaults=%s' % pprint.pformat(defaults).strip()) 
    173              
     173 
    174174        fd.write(')') 
    175175 
     
    177177    def _parse_dict(self, node, fd, deep, first): 
    178178        self._parse_list(node, fd, deep, first) 
    179          
     179 
    180180 
    181181 
     
    184184    if tree.nodeName != 'config': 
    185185        raise RuntimeError('%s is no valid cxml file' % xml) 
    186      
     186 
    187187    # out = sys.__stdout__ 
    188188    out = open(python, 'w') 
    189      
     189 
    190190    out.write('# auto generated file\n\n') 
    191191    out.write('from kaa.config import Var, Group, Dict, List, Config\n\n') 
  • trunk/base/src/extensions/inotify/__init__.py

    <
    r3069 r3686  
    3535import fcntl 
    3636import select 
     37import errno 
     38import socket 
    3739 
    3840# kaa imports