********************************************* exif.py RefactoringTool: Skipping implicit fixer: buffer RefactoringTool: Skipping implicit fixer: idioms RefactoringTool: Skipping implicit fixer: set_literal RefactoringTool: Skipping implicit fixer: ws_comma RefactoringTool: Refactored exif.py --- exif.py (original) +++ exif.py (refactored) @@ -175,7 +175,7 @@ values = self._raw_value.split() if len(values) > 1: # Make values a notifying list - values = map(self._convert_to_python, values) + values = list(map(self._convert_to_python, values)) self._value = NotifyingList(values) self._value.register_listener(self) self._value_cookie = False @@ -191,7 +191,7 @@ def _set_value(self, value): if isinstance(value, (list, tuple)): - raw_values = map(self._convert_to_string, value) + raw_values = list(map(self._convert_to_string, value)) self.raw_value = ' '.join(raw_values) else: self.raw_value = self._convert_to_string(value) @@ -311,7 +311,7 @@ elif self.type in ('Long', 'SLong'): try: - return long(value) + return int(value) except ValueError: raise ExifValueError(value, self.type) @@ -354,7 +354,7 @@ return value.strftime(self._date_formats[0]) else: return value.strftime('%s 00:00:00' % self._date_formats[0]) - elif isinstance(value, unicode): + elif isinstance(value, str): try: return value.encode('utf-8') except UnicodeEncodeError: @@ -365,7 +365,7 @@ raise ExifValueError(value, self.type) elif self.type in ('Byte', 'SByte'): - if isinstance(value, unicode): + if isinstance(value, str): try: return value.encode('utf-8') except UnicodeEncodeError: @@ -390,7 +390,7 @@ else: return 'charset="%s" %s' % (charset, val) - if isinstance(value, unicode): + if isinstance(value, str): try: return value.encode('utf-8') except UnicodeEncodeError: @@ -413,13 +413,13 @@ raise ExifValueError(value, self.type) elif self.type == 'Long': - if isinstance(value, (int, long)) and value >= 0: + if isinstance(value, int) and value >= 0: return str(value) else: raise ExifValueError(value, self.type) elif self.type == 'SLong': - if isinstance(value, (int, long)): + if isinstance(value, int): return str(value) else: raise ExifValueError(value, self.type) @@ -437,7 +437,7 @@ raise ExifValueError(value, self.type) elif self.type == 'Undefined': - if isinstance(value, unicode): + if isinstance(value, str): try: return string_to_undefined(value.encode('utf-8')) except UnicodeEncodeError: @@ -509,7 +509,7 @@ # Update the cache of EXIF tags keys = self._metadata._image._exifKeys() self._metadata._keys['exif'] = keys - cached = self._metadata._tags['exif'].keys() + cached = list(self._metadata._tags['exif'].keys()) for key in cached: if key not in keys: del self._metadata._tags['exif'][key] RefactoringTool: Files that need to be modified: RefactoringTool: exif.py **************************************************** iptc.py RefactoringTool: Skipping implicit fixer: buffer RefactoringTool: Skipping implicit fixer: idioms RefactoringTool: Skipping implicit fixer: set_literal RefactoringTool: Skipping implicit fixer: ws_comma RefactoringTool: Refactored iptc.py --- iptc.py (original) +++ iptc.py (refactored) @@ -192,7 +192,7 @@ def _compute_values(self): # Lazy computation of the values from the raw values self._values = \ - NotifyingList(map(self._convert_to_python, self._raw_values)) + NotifyingList(list(map(self._convert_to_python, self._raw_values))) self._values.register_listener(self) self._values_cookie = False @@ -204,7 +204,7 @@ def _set_values(self, values): if not isinstance(values, (list, tuple)): raise TypeError('Expecting a list of values') - self.raw_value = map(self._convert_to_string, values) + self.raw_value = list(map(self._convert_to_string, values)) if isinstance(self._values, NotifyingList): self._values.unregister_listener(self) @@ -323,7 +323,7 @@ raise IptcValueError(value, self.type) elif self.type == 'String': - if isinstance(value, unicode): + if isinstance(value, str): try: return value.encode('utf-8') except UnicodeEncodeError: RefactoringTool: Files that were modified: RefactoringTool: iptc.py **************************************************** main.py RefactoringTool: Skipping implicit fixer: buffer RefactoringTool: Skipping implicit fixer: idioms RefactoringTool: Skipping implicit fixer: set_literal RefactoringTool: Skipping implicit fixer: ws_comma RefactoringTool: Refactored main.py --- main.py (original) +++ main.py (refactored) @@ -34,7 +34,7 @@ args = sys.argv if len(args) != 2: - print 'Usage: %s image_file' % args[0] + print('Usage: %s image_file' % args[0]) sys.exit(-1) metadata = ImageMetadata(args[1]) @@ -42,11 +42,11 @@ for key in metadata.exif_keys: tag = metadata[key] - print '%-45s%-11s%s' % (key, tag.type, str(tag)) + print('%-45s%-11s%s' % (key, tag.type, str(tag))) for key in metadata.iptc_keys: tag = metadata[key] - print '%-45s%-11s%s' % (key, tag.type, str(tag)) + print('%-45s%-11s%s' % (key, tag.type, str(tag))) # TODO: print XMP tags. RefactoringTool: Files that were modified: RefactoringTool: main.py ************************************ metadata.py RefactoringTool: Skipping implicit fixer: buffer RefactoringTool: Skipping implicit fixer: idioms RefactoringTool: Skipping implicit fixer: set_literal RefactoringTool: Skipping implicit fixer: ws_comma RefactoringTool: Refactored metadata.py --- metadata.py (original) +++ metadata.py (refactored) @@ -420,7 +420,7 @@ return try: name = codecs.lookup(charset).name - except LookupError, error: + except LookupError as error: raise ValueError(*error.args) else: charsets = {'utf-8': '\x1b%G'} RefactoringTool: Files that were modified: RefactoringTool: metadata.py ********************************** preview.py RefactoringTool: Skipping implicit fixer: buffer RefactoringTool: Skipping implicit fixer: idioms RefactoringTool: Skipping implicit fixer: set_literal RefactoringTool: Skipping implicit fixer: ws_comma RefactoringTool: No files need to be modified. ****************************************** utils.py RefactoringTool: Skipping implicit fixer: buffer RefactoringTool: Skipping implicit fixer: idioms RefactoringTool: Skipping implicit fixer: set_literal RefactoringTool: Skipping implicit fixer: ws_comma RefactoringTool: Refactored utils.py --- utils.py (original) +++ utils.py (refactored) @@ -145,7 +145,7 @@ :return: the corresponding decoded string :rtype: string """ - return ''.join(map(lambda x: chr(int(x)), undefined.rstrip().split(' '))) + return ''.join([chr(int(x)) for x in undefined.rstrip().split(' ')]) def string_to_undefined(sequence): @@ -161,7 +161,7 @@ :return: the corresponding undefined string :rtype: string """ - return ''.join(map(lambda x: '%d ' % ord(x), sequence)).rstrip() + return ''.join(['%d ' % ord(x) for x in sequence]).rstrip() class Rational(object): @@ -186,8 +186,8 @@ if denominator == 0: msg = 'Denominator of a rational number cannot be zero.' raise ZeroDivisionError(msg) - self._numerator = long(numerator) - self._denominator = long(denominator) + self._numerator = int(numerator) + self._denominator = int(denominator) @property def numerator(self): @@ -217,7 +217,7 @@ if match is None: raise ValueError('Invalid format for a rational: %s' % string) gd = match.groupdict() - return Rational(long(gd['numerator']), long(gd['denominator'])) + return Rational(int(gd['numerator']), int(gd['denominator'])) def to_float(self): """ RefactoringTool: Files that were modified: RefactoringTool: utils.py *********************************************** xmp.py RefactoringTool: Skipping implicit fixer: buffer RefactoringTool: Skipping implicit fixer: idioms RefactoringTool: Skipping implicit fixer: set_literal RefactoringTool: Skipping implicit fixer: ws_comma RefactoringTool: Refactored xmp.py --- xmp.py (original) +++ xmp.py (refactored) @@ -187,12 +187,12 @@ type = self.type[4:] if type.lower().startswith('closed choice of'): type = type[17:] - self._value = map(lambda x: self._convert_to_python(x, type), self._raw_value) + self._value = [self._convert_to_python(x, type) for x in self._raw_value] elif self.type == 'Lang Alt': self._value = {} - for k, v in self._raw_value.iteritems(): + for k, v in self._raw_value.items(): try: - self._value[unicode(k, 'utf-8')] = unicode(v, 'utf-8') + self._value[str(k, 'utf-8')] = str(v, 'utf-8') except TypeError: raise XmpValueError(self._raw_value, type) elif self.type.lower().startswith('closed choice of'): @@ -220,10 +220,10 @@ stype = self.type[4:] if stype.lower().startswith('closed choice of'): stype = stype[17:] - self.raw_value = map(lambda x: self._convert_to_string(x, stype), value) + self.raw_value = [self._convert_to_string(x, stype) for x in value] elif type == 'LangAlt': raw_value = {} - for k, v in value.iteritems(): + for k, v in value.items(): try: raw_value[k.encode('utf-8')] = v.encode('utf-8') except TypeError: @@ -349,7 +349,7 @@ elif type in ('AgentName', 'ProperName', 'Text'): try: - return unicode(value, 'utf-8') + return str(value, 'utf-8') except TypeError: raise XmpValueError(value, type) @@ -413,7 +413,7 @@ raise XmpValueError(value, type) elif type == 'Integer': - if isinstance(value, (int, long)): + if isinstance(value, int): return str(value) else: raise XmpValueError(value, type) @@ -425,7 +425,7 @@ raise XmpValueError(value, type) elif type in ('AgentName', 'ProperName', 'Text', 'URI', 'URL'): - if isinstance(value, unicode): + if isinstance(value, str): try: return value.encode('utf-8') except UnicodeEncodeError: @@ -443,7 +443,7 @@ elif type == '': # Unknown type, assume string - if isinstance(value, unicode): + if isinstance(value, str): try: return value.encode('utf-8') except UnicodeEncodeError: RefactoringTool: Files that were modified: RefactoringTool: xmp.py