Changeset 198:3231c0e271fc

Show
Ignore:
Timestamp:
06/09/09 01:43:25 (15 months ago)
Author:
Benjamin Wohlwend <bw@…>
Branch:
default
Tags:
tip
Message:

Whitespace removal

Location:
src
Files:
9 modified

Legend:

Unmodified
Added
Removed
  • src/contrib/modeltest.py

    r137 r198  
    9696        """ 
    9797        Tests self.model's implementation of QtCore.QAbstractItemModel::rowCount() and hasChildren() 
    98          
     98 
    9999        self.models that are dynamically populated are not as fully tested here. 
    100100        """ 
     
    113113            if rows > 0: 
    114114                assert(self.model.hasChildren(secondlvl) == True) 
    115          
     115 
    116116        # The self.models rowCount() is tested more extensively in checkChildren, 
    117117        # but this catches the big mistakes 
     
    248248        if variant.isValid(): 
    249249            assert( variant.canConvert( QtCore.QVariant.String ) ) 
    250          
     250 
    251251        # General Purpose roles that should return a QSize 
    252252        variant = self.model.data(self.model.index(0,0,QtCore.QModelIndex()), QtCore.Qt.SizeHintRole) 
     
    258258        if variant.isValid(): 
    259259            assert( variant.canConvert( QtCore.QVariant.Font ) ) 
    260          
     260 
    261261        # Check that the alignment is one we know about 
    262262        variant = self.model.data(self.model.index(0,0,QtCore.QModelIndex()), QtCore.Qt.TextAlignmentRole) 
  • src/contrib/plist_parser.py

    r145 r198  
    5959        self.__stack = [] 
    6060        self.__plist = self.__key = self.__characters = None 
    61         # For reducing runtime type checking,  
     61        # For reducing runtime type checking, 
    6262        # the parser caches top level object type. 
    6363        self.__in_dict = False 
    6464 
    6565    def endDocument(self): 
    66         self._assert(self.__plist is not None, "A top level element must be <plist>.")         
     66        self._assert(self.__plist is not None, "A top level element must be <plist>.") 
    6767        self._assert( 
    6868            len(self.__stack) is 0, 
     
    164164    # http://www.apple.com/DTDs/PropertyList-1.0.dtd says: 
    165165    # 
    166     # Contents should conform to a subset of ISO 8601  
     166    # Contents should conform to a subset of ISO 8601 
    167167    # (in particular, YYYY '-' MM '-' DD 'T' HH ':' MM ':' SS 'Z'. 
    168168    # Smaller units may be omitted with a loss of precision) 
     
    172172    def _parse_date(self, name, content): 
    173173        import datetime 
    174          
     174 
    175175        units = ('year', 'month', 'day', 'hour', 'minute', 'second', ) 
    176176        pattern = XmlPropertyListParser.DATETIME_PATTERN 
     
    231231        else: 
    232232            raise TypeError('Can\'t convert %s to file-like-object' % type(io_or_string)) 
    233          
     233 
    234234    def _parse_using_etree(self, xml_input): 
    235235        from xml.etree.cElementTree import iterparse 
     
    270270        Parse the property list (`.plist`, `.xml, for example) ``xml_input``, 
    271271        which can be either a string or a file-like object. 
    272          
     272 
    273273        >>> parser = XmlPropertyListParser() 
    274274        >>> parser.parse(r'<plist version="1.0">' 
  • src/setup.py

    r142 r198  
    11from setuptools import setup 
    22import shutil 
    3 import os  
     3import os 
    44APP = ['underCover.py'] 
    5 OPTIONS = {'argv_emulation': True,  
     5OPTIONS = {'argv_emulation': True, 
    66           'includes': ['sip', 'PyQt4._qt'], 
    77           'iconfile': 'undercover/gui/img/logo.icns'} 
    8   
     8 
    99setup( 
    1010    app=APP, 
  • src/undercover/fetchers/amazon.py

    r124 r198  
    44# of this software and associated documentation files (the "Software"), to deal 
    55# in the Software without restriction, including without limitation the rights 
    6 # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell  
    7 # copies of the Software, and to permit persons to whom the Software is  
     6# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 
     7# copies of the Software, and to permit persons to whom the Software is 
    88# furnished to do so, subject to the following conditions: 
    99# 
    10 # The above copyright notice and this permission notice shall be included in  
     10# The above copyright notice and this permission notice shall be included in 
    1111# all copies or substantial portions of the Software. 
    1212# 
    13 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR  
    14 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,  
     13# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 
     14# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 
    1515# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 
    16 # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER  
     16# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 
    1717# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 
    1818# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 
    19 # SOFTWARE.  
     19# SOFTWARE. 
    2020 
    2121import urllib2 
     
    2828 
    2929class Fetcher(AbstractFetcher): 
    30     """  
     30    """ 
    3131    Gets covers from Amazon's web service. 
    32      
     32 
    3333    Settings: 
    3434        String    amazon/api_key    AWS API Key 
    3535        String    amazon/country    Which country URL should be used 
    3636    """ 
    37      
     37 
    3838    IDENT = 'Amazon' 
    3939 
     
    4646        'Canada'         :'http://webservices.amazon.ca/onca/xml?Service=AWSECommerceService', 
    4747        } 
    48      
     48 
    4949    COUNTRY_LIST = ('USA', 'United Kingdom', 'Germany', 'Japan', 'France', 'Canada') 
    5050    settings.set_choice('amazon/country', COUNTRY_LIST) 
  • src/undercover/fetchers/google.py

    r109 r198  
    7575 
    7676register(GoogleImageFetcher)               
    77          
  • src/undercover/fetchers/lastfm.py

    r134 r198  
    44# of this software and associated documentation files (the "Software"), to deal 
    55# in the Software without restriction, including without limitation the rights 
    6 # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell  
    7 # copies of the Software, and to permit persons to whom the Software is  
     6# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 
     7# copies of the Software, and to permit persons to whom the Software is 
    88# furnished to do so, subject to the following conditions: 
    99# 
    10 # The above copyright notice and this permission notice shall be included in  
     10# The above copyright notice and this permission notice shall be included in 
    1111# all copies or substantial portions of the Software. 
    1212# 
    13 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR  
    14 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,  
     13# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 
     14# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 
    1515# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 
    16 # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER  
     16# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 
    1717# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 
    1818# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 
    19 # SOFTWARE.  
     19# SOFTWARE. 
    2020 
    2121import urllib2 
     
    2626 
    2727class LastFMFetcher(AbstractFetcher): 
    28     """  
     28    """ 
    2929    Gets covers from Last.fm's web service. 
    30      
     30 
    3131    Settings: 
    3232        String    lastfm/api_key    Last.fm API Key 
     
    3737    URL = 'http://ws.audioscrobbler.com/2.0/?method=album.getinfo&' + \ 
    3838          'api_key=%(key)s&artist=%(artist)s&album=%(album)s' 
    39            
    40            
     39 
     40 
    4141    def is_enabled(self): 
    4242        return settings['lastfm/is_enabled'] 
  • src/undercover/gui/designer/generate_ui.py

    r168 r198  
    55# of this software and associated documentation files (the "Software"), to deal 
    66# in the Software without restriction, including without limitation the rights 
    7 # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell  
    8 # copies of the Software, and to permit persons to whom the Software is  
     7# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 
     8# copies of the Software, and to permit persons to whom the Software is 
    99# furnished to do so, subject to the following conditions: 
    1010# 
    11 # The above copyright notice and this permission notice shall be included in  
     11# The above copyright notice and this permission notice shall be included in 
    1212# all copies or substantial portions of the Software. 
    1313# 
    14 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR  
    15 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,  
     14# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 
     15# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 
    1616# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 
    17 # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER  
     17# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 
    1818# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 
    1919# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 
    20 # SOFTWARE.  
     20# SOFTWARE. 
    2121 
    2222from codecs import open 
  • src/undercover/net/server.py

    r180 r198  
    66# of this software and associated documentation files (the "Software"), to deal 
    77# in the Software without restriction, including without limitation the rights 
    8 # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell  
    9 # copies of the Software, and to permit persons to whom the Software is  
     8# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 
     9# copies of the Software, and to permit persons to whom the Software is 
    1010# furnished to do so, subject to the following conditions: 
    1111# 
    12 # The above copyright notice and this permission notice shall be included in  
     12# The above copyright notice and this permission notice shall be included in 
    1313# all copies or substantial portions of the Software. 
    1414# 
    15 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR  
    16 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,  
     15# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 
     16# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 
    1717# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 
    18 # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER  
     18# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 
    1919# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 
    2020# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 
    21 # SOFTWARE.  
     21# SOFTWARE. 
    2222 
    2323from __future__ import with_statement 
     
    6868 
    6969    lock = QtCore.QMutex() 
    70      
     70 
    7171    def __init__(self, *args, **kwargs): 
    7272        global parent 
    7373        self.emitter = QtCore.QObject() 
    74         QtCore.QObject.connect(self.emitter, QtCore.SIGNAL('new_query'),  
     74        QtCore.QObject.connect(self.emitter, QtCore.SIGNAL('new_query'), 
    7575                               parent.show_new_query, QtCore.Qt.QueuedConnection) 
    7676        QtCore.QObject.connect(self.emitter, QtCore.SIGNAL('showMessage(QString, int)'), 
     
    134134                        self.send_xml(self.NO_COVER_FOUND_XML) 
    135135                    return 
    136          
     136 
    137137        elif 'example.com/serve' in self.path: 
    138138            appdir = settings['main/appdir'] 
     
    148148            self.end_headers() 
    149149            self.wfile.write(data) 
    150             self.emitter.emit(QtCore.SIGNAL('showMessage(QString, int)'),  
     150            self.emitter.emit(QtCore.SIGNAL('showMessage(QString, int)'), 
    151151                                    u'Served image for %s to iTunes' % unicode(image.album_query), 0) 
    152152            return 
    153              
     153 
    154154        # Otherwise, proxy the request to the real destination. 
    155155        soc = socket.socket(socket.AF_INET, socket.SOCK_STREAM) 
     
    200200    do_PUT  = do_GET 
    201201    do_DELETE=do_GET 
    202      
     202 
    203203    def try_itms(self, album_query): 
    204204        """ 
     
    229229                    md5.update(new_data) 
    230230                    new_path = u'%s_%s' % (album_query.artist, album_query.album) 
    231                     new_path = Image.disallowed_chars.sub('_', new_path)[:60] + '_%s.png' % md5.hexdigest()            
     231                    new_path = Image.disallowed_chars.sub('_', new_path)[:60] + '_%s.png' % md5.hexdigest() 
    232232                    new_file = open(os.path.join(appdir, 'fullsize', new_path), 'wb') 
    233233                    new_file.write(new_data) 
    234234                    new_file.close() 
    235235                    with QtCore.QMutexLocker(self.lock): 
    236                         i = Image(path=new_path, url=None, comes_from='iTunes (locked)',  
     236                        i = Image(path=new_path, url=None, comes_from='iTunes (locked)', 
    237237                                  bytes=len(new_data), album_query=album_query) 
    238238                    album_query.best_match = i 
     
    241241                    pass 
    242242        return False 
    243          
     243 
    244244    def send_match_xml(self, image): 
    245245        xml = self.COVER_INFO_XML % image.id 
     
    272272    def stop(self): 
    273273        self.run = False 
    274             
     274 
    275275    def serve(self): 
    276276        while self.run: 
     
    284284    def start(self): 
    285285        self.is_running = True 
    286         self.proxy = StoppableHTTPServer((settings['main/our_proxy_host'],  
     286        self.proxy = StoppableHTTPServer((settings['main/our_proxy_host'], 
    287287                                          settings['main/our_proxy_port']), 
    288288                                          CoverArtProxyHandler) 
    289289        threading.Thread(target=self.proxy.serve).start() 
    290         return QtCore.QCoreApplication.translate('Proxy', 'Proxy started at')+ ' %s:%i' % (self.proxy.server_address[0],  
     290        return QtCore.QCoreApplication.translate('Proxy', 'Proxy started at')+ ' %s:%i' % (self.proxy.server_address[0], 
    291291                                           self.proxy.server_address[1]) 
    292      
     292 
    293293    def stop(self): 
    294294        self.proxy.socket.close() 
  • src/undercover/util/settings.py

    r188 r198  
    44# of this software and associated documentation files (the "Software"), to deal 
    55# in the Software without restriction, including without limitation the rights 
    6 # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell  
    7 # copies of the Software, and to permit persons to whom the Software is  
     6# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 
     7# copies of the Software, and to permit persons to whom the Software is 
    88# furnished to do so, subject to the following conditions: 
    99# 
    10 # The above copyright notice and this permission notice shall be included in  
     10# The above copyright notice and this permission notice shall be included in 
    1111# all copies or substantial portions of the Software. 
    1212# 
    13 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR  
    14 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,  
     13# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 
     14# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 
    1515# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 
    16 # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER  
     16# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 
    1717# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 
    1818# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 
    19 # SOFTWARE.  
     19# SOFTWARE. 
    2020 
    2121import pickle 
     
    2727    A wrapper around QSettings that makes automatic handling of settings dialogs and 
    2828    access of settings easier. 
    29      
     29 
    3030    The name of the setting keys follows the pattern "group_name/key_name". This should 
    31     be reflected in the object names of associated QWidgets in the form of  
     31    be reflected in the object names of associated QWidgets in the form of 
    3232    "group_name__key_name". 
    33      
     33 
    3434    This class is a singleton. It should be considered as not thread safe. 
    3535    ''' 
    36      
     36 
    3737    def __new__(cls): 
    3838        """Singleton pattern""" 
     
    4242 
    4343    __settings = QSettings(QSettings.IniFormat, QSettings.UserScope, 'piquadrat.ch', 'underCover') 
    44      
     44 
    4545    __default_settings = { 
    4646    #    KEYNAME                   DEFAULT      TYPE        IS REQUIRED  DATASTRUCTURE 
     
    5656        'main/fetch_all'        : (True,        bool,                              ), 
    5757        'main/covers_view'      : (0,           int,                               ), 
    58          
     58 
    5959        'iTunes/cache'          : (True,        bool,                              ), 
    6060        'iTunes/library_path'   : (None,        unicode,                           ), 
    61          
     61 
    6262        'export/filename'       : (u'cover.png',unicode,    True,                  ), 
    6363        'export/overwrite'      : (True,        bool,                              ), 
    64          
     64 
    6565        'google/is_enabled'     : (True,        bool,                              ), 
    6666        'google/limit'          : (5,           int,                               ), 
    6767        'google/query_add'      : (u'artwork',  unicode,                           ), 
    6868        'google/safe_mode'      : (True,        bool,                              ), 
    69          
     69 
    7070        'amazon/is_enabled'     : (False,       bool,                              ), 
    7171        'amazon/api_key'        : (None,        unicode,    True                   ), 
    7272        'amazon/country'        : (0,           list,       False,       []        ), 
    73          
     73 
    7474        'lastfm/is_enabled'     : (True,       bool,                              ), 
    7575        'lastfm/api_key'        : ('f2e1eb43a86afaa065e6d826a977a0a4',        unicode,    True,                  ), 
    7676    } 
    77      
     77 
    7878    def __getitem__(self, key): 
    7979        ''' 
     
    8585        else: 
    8686            return self.__default_settings[key][0] 
    87      
     87 
    8888    def __setitem__(self, key, value): 
    8989        ''' 
     
    9898                    raise TypeError, 'type of %s is %s, expected %s' % (key, str(type(key)), str(self.typeof(key))) 
    9999            self.__settings.setValue(key, QVariant(pickle.dumps(value, protocol=0))) 
    100          
     100 
    101101    def __haskey__(self, key): 
    102102        return self.__settings.contains(key) or key in self.__default_settings 
    103      
     103 
    104104    def setValue(self, key, value): 
    105105        ''' 
     
    107107        ''' 
    108108        self.__settings.setValue(key, value) 
    109      
     109 
    110110    def value(self, key, default=QVariant()): 
    111111        ''' 
     
    113113        ''' 
    114114        return self.__settings.value(key, default) 
    115      
     115 
    116116    def contains(self, key): 
    117117        ''' 
    118118        Direct access to the internal QSettings instance 
    119119        ''' 
    120         return self.__settings.contains(key)         
     120        return self.__settings.contains(key) 
    121121    def typeof(self, key): 
    122122        ''' 
     
    124124        ''' 
    125125        return self.__default_settings[key][1] 
    126      
     126 
    127127    def keys(self, group=None): 
    128128        ''' 
     
    134134        else: 
    135135            return [key for key in self.__default_settings.keys() if key.startswith(group)] 
    136          
     136 
    137137    def is_required(self, key): 
    138138        ''' 
    139139        Returns True if key is required, False otherwise. Requiredness should only be 
    140140        evaluated if the group of this key is enabled. 
    141          
     141 
    142142        Does not handle KeyErrors 
    143143        ''' 
     
    146146        else: 
    147147            return False 
    148          
     148 
    149149    def set_choice(self, key, choices): 
    150150        if len(self.__default_settings[key]) > 3: 
     
    154154        else: 
    155155            raise KeyError, '%s has no choices list' % key 
    156          
     156 
    157157    def choice(self, key): 
    158158        if len(self.__default_settings[key]) > 3: