##// END OF EJS Templates
python3: fix usage of int/long
super-admin -
r4935:18be5f3a default
parent child Browse files
Show More
@@ -214,7 +214,7 b' def get_user_or_error(userid):'
214 from rhodecode.model.user import UserModel
214 from rhodecode.model.user import UserModel
215 user_model = UserModel()
215 user_model = UserModel()
216
216
217 if isinstance(userid, (int, long)):
217 if isinstance(userid, int):
218 try:
218 try:
219 user = user_model.get_user(userid)
219 user = user_model.get_user(userid)
220 except ValueError:
220 except ValueError:
@@ -237,7 +237,7 b' def get_repo_or_error(repoid):'
237 from rhodecode.model.repo import RepoModel
237 from rhodecode.model.repo import RepoModel
238 repo_model = RepoModel()
238 repo_model = RepoModel()
239
239
240 if isinstance(repoid, (int, long)):
240 if isinstance(repoid, int):
241 try:
241 try:
242 repo = repo_model.get_repo(repoid)
242 repo = repo_model.get_repo(repoid)
243 except ValueError:
243 except ValueError:
@@ -260,7 +260,7 b' def get_repo_group_or_error(repogroupid)'
260 from rhodecode.model.repo_group import RepoGroupModel
260 from rhodecode.model.repo_group import RepoGroupModel
261 repo_group_model = RepoGroupModel()
261 repo_group_model = RepoGroupModel()
262
262
263 if isinstance(repogroupid, (int, long)):
263 if isinstance(repogroupid, int):
264 try:
264 try:
265 repo_group = repo_group_model._get_repo_group(repogroupid)
265 repo_group = repo_group_model._get_repo_group(repogroupid)
266 except ValueError:
266 except ValueError:
@@ -283,7 +283,7 b' def get_user_group_or_error(usergroupid)'
283 from rhodecode.model.user_group import UserGroupModel
283 from rhodecode.model.user_group import UserGroupModel
284 user_group_model = UserGroupModel()
284 user_group_model = UserGroupModel()
285
285
286 if isinstance(usergroupid, (int, long)):
286 if isinstance(usergroupid, int):
287 try:
287 try:
288 user_group = user_group_model.get_group(usergroupid)
288 user_group = user_group_model.get_group(usergroupid)
289 except ValueError:
289 except ValueError:
@@ -472,7 +472,7 b' class RhodeCodeAuthPluginBase(object):'
472 from rhodecode.authentication import plugin_default_auth_ttl
472 from rhodecode.authentication import plugin_default_auth_ttl
473 cache_ttl = plugin_default_auth_ttl
473 cache_ttl = plugin_default_auth_ttl
474
474
475 if isinstance(self.AUTH_CACHE_TTL, (int, long)):
475 if isinstance(self.AUTH_CACHE_TTL, int):
476 # plugin cache set inside is more important than the settings value
476 # plugin cache set inside is more important than the settings value
477 cache_ttl = self.AUTH_CACHE_TTL
477 cache_ttl = self.AUTH_CACHE_TTL
478 elif plugin_settings.get('cache_ttl'):
478 elif plugin_settings.get('cache_ttl'):
@@ -47,7 +47,7 b' if PY3:'
47 MAXSIZE = sys.maxsize
47 MAXSIZE = sys.maxsize
48 else:
48 else:
49 string_types = str,
49 string_types = str,
50 integer_types = (int, long)
50 integer_types = int
51 class_types = (type, types.ClassType)
51 class_types = (type, types.ClassType)
52 text_type = unicode
52 text_type = unicode
53 binary_type = str
53 binary_type = str
@@ -1741,7 +1741,7 b' class Repository(Base, BaseModel):'
1741
1741
1742 @classmethod
1742 @classmethod
1743 def get_by_id_or_repo_name(cls, repoid):
1743 def get_by_id_or_repo_name(cls, repoid):
1744 if isinstance(repoid, (int, long)):
1744 if isinstance(repoid, int):
1745 try:
1745 try:
1746 repo = cls.get(repoid)
1746 repo = cls.get(repoid)
1747 except ValueError:
1747 except ValueError:
@@ -1757,7 +1757,7 b' class Repository(Base, BaseModel):'
1757
1757
1758 @classmethod
1758 @classmethod
1759 def get_by_id_or_repo_name(cls, repoid):
1759 def get_by_id_or_repo_name(cls, repoid):
1760 if isinstance(repoid, (int, long)):
1760 if isinstance(repoid, int):
1761 try:
1761 try:
1762 repo = cls.get(repoid)
1762 repo = cls.get(repoid)
1763 except ValueError:
1763 except ValueError:
@@ -1770,7 +1770,7 b' class Repository(Base, BaseModel):'
1770
1770
1771 @classmethod
1771 @classmethod
1772 def get_by_id_or_repo_name(cls, repoid):
1772 def get_by_id_or_repo_name(cls, repoid):
1773 if isinstance(repoid, (int, long)):
1773 if isinstance(repoid, int):
1774 try:
1774 try:
1775 repo = cls.get(repoid)
1775 repo = cls.get(repoid)
1776 except ValueError:
1776 except ValueError:
@@ -1770,7 +1770,7 b' class Repository(Base, BaseModel):'
1770
1770
1771 @classmethod
1771 @classmethod
1772 def get_by_id_or_repo_name(cls, repoid):
1772 def get_by_id_or_repo_name(cls, repoid):
1773 if isinstance(repoid, (int, long)):
1773 if isinstance(repoid, int):
1774 try:
1774 try:
1775 repo = cls.get(repoid)
1775 repo = cls.get(repoid)
1776 except ValueError:
1776 except ValueError:
@@ -1790,7 +1790,7 b' class Repository(Base, BaseModel):'
1790
1790
1791 @classmethod
1791 @classmethod
1792 def get_by_id_or_repo_name(cls, repoid):
1792 def get_by_id_or_repo_name(cls, repoid):
1793 if isinstance(repoid, (int, long)):
1793 if isinstance(repoid, int):
1794 try:
1794 try:
1795 repo = cls.get(repoid)
1795 repo = cls.get(repoid)
1796 except ValueError:
1796 except ValueError:
@@ -1848,7 +1848,7 b' class Repository(Base, BaseModel):'
1848
1848
1849 @classmethod
1849 @classmethod
1850 def get_by_id_or_repo_name(cls, repoid):
1850 def get_by_id_or_repo_name(cls, repoid):
1851 if isinstance(repoid, (int, long)):
1851 if isinstance(repoid, int):
1852 try:
1852 try:
1853 repo = cls.get(repoid)
1853 repo = cls.get(repoid)
1854 except ValueError:
1854 except ValueError:
@@ -1854,7 +1854,7 b' class Repository(Base, BaseModel):'
1854
1854
1855 @classmethod
1855 @classmethod
1856 def get_by_id_or_repo_name(cls, repoid):
1856 def get_by_id_or_repo_name(cls, repoid):
1857 if isinstance(repoid, (int, long)):
1857 if isinstance(repoid, int):
1858 try:
1858 try:
1859 repo = cls.get(repoid)
1859 repo = cls.get(repoid)
1860 except ValueError:
1860 except ValueError:
@@ -1885,7 +1885,7 b' class Repository(Base, BaseModel):'
1885
1885
1886 @classmethod
1886 @classmethod
1887 def get_by_id_or_repo_name(cls, repoid):
1887 def get_by_id_or_repo_name(cls, repoid):
1888 if isinstance(repoid, (int, long)):
1888 if isinstance(repoid, int):
1889 try:
1889 try:
1890 repo = cls.get(repoid)
1890 repo = cls.get(repoid)
1891 except ValueError:
1891 except ValueError:
@@ -28,7 +28,7 b' def _obj_dump(obj):'
28 return list(obj)
28 return list(obj)
29 elif isinstance(obj, datetime.datetime):
29 elif isinstance(obj, datetime.datetime):
30 r = obj.isoformat()
30 r = obj.isoformat()
31 if isinstance(obj.microsecond, (int, long)):
31 if isinstance(obj.microsecond, int):
32 r = r[:23] + r[26:]
32 r = r[:23] + r[26:]
33 if r.endswith('+00:00'):
33 if r.endswith('+00:00'):
34 r = r[:-6] + 'Z'
34 r = r[:-6] + 'Z'
@@ -39,7 +39,7 b' def _obj_dump(obj):'
39 if is_aware(obj):
39 if is_aware(obj):
40 raise TypeError("Time-zone aware times are not JSON serializable")
40 raise TypeError("Time-zone aware times are not JSON serializable")
41 r = obj.isoformat()
41 r = obj.isoformat()
42 if isinstance(obj.microsecond, (int, long)):
42 if isinstance(obj.microsecond, int):
43 r = r[:12]
43 r = r[:12]
44 return r
44 return r
45 elif hasattr(obj, '__json__'):
45 elif hasattr(obj, '__json__'):
@@ -788,7 +788,7 b' class BaseRepository(object):'
788 raise TypeError("commit_id must be a string value got {} instead".format(type(commit_id)))
788 raise TypeError("commit_id must be a string value got {} instead".format(type(commit_id)))
789
789
790 def _validate_commit_idx(self, commit_idx):
790 def _validate_commit_idx(self, commit_idx):
791 if not isinstance(commit_idx, (int, long)):
791 if not isinstance(commit_idx, int):
792 raise TypeError("commit_idx must be a numeric value")
792 raise TypeError("commit_idx must be a numeric value")
793
793
794 def _validate_branch_name(self, branch_name):
794 def _validate_branch_name(self, branch_name):
@@ -76,7 +76,7 b' class BaseModel(object):'
76
76
77 if isinstance(instance, cls):
77 if isinstance(instance, cls):
78 return instance
78 return instance
79 elif isinstance(instance, (int, long)):
79 elif isinstance(instance, int):
80 if isinstance(cls, tuple):
80 if isinstance(cls, tuple):
81 # if we pass multi instances we pick first to .get()
81 # if we pass multi instances we pick first to .get()
82 cls = cls[0]
82 cls = cls[0]
@@ -523,7 +523,7 b' class CommentsModel(BaseModel):'
523 # would return 3 here
523 # would return 3 here
524 comment_version = ChangesetCommentHistory.get_version(comment_id)
524 comment_version = ChangesetCommentHistory.get_version(comment_id)
525
525
526 if isinstance(version, (int, long)) and (comment_version - version) != 1:
526 if isinstance(version, int) and (comment_version - version) != 1:
527 log.warning(
527 log.warning(
528 'Version mismatch comment_version {} submitted {}, skipping'.format(
528 'Version mismatch comment_version {} submitted {}, skipping'.format(
529 comment_version-1, # -1 since note above
529 comment_version-1, # -1 since note above
@@ -46,11 +46,11 b' class IntegrationModel(BaseModel):'
46 def __get_integration(self, integration):
46 def __get_integration(self, integration):
47 if isinstance(integration, Integration):
47 if isinstance(integration, Integration):
48 return integration
48 return integration
49 elif isinstance(integration, (int, long)):
49 elif isinstance(integration, int):
50 return self.sa.query(Integration).get(integration)
50 return self.sa.query(Integration).get(integration)
51 else:
51 else:
52 if integration:
52 if integration:
53 raise Exception('integration must be int, long or Instance'
53 raise Exception('integration must be int or Instance'
54 ' of Integration got %s' % type(integration))
54 ' of Integration got %s' % type(integration))
55
55
56 def create(self, IntegrationType, name, enabled, repo, repo_group,
56 def create(self, IntegrationType, name, enabled, repo, repo_group,
@@ -47,11 +47,11 b' class NotificationModel(BaseModel):'
47 def __get_notification(self, notification):
47 def __get_notification(self, notification):
48 if isinstance(notification, Notification):
48 if isinstance(notification, Notification):
49 return notification
49 return notification
50 elif isinstance(notification, (int, long)):
50 elif isinstance(notification, int):
51 return Notification.get(notification)
51 return Notification.get(notification)
52 else:
52 else:
53 if notification:
53 if notification:
54 raise Exception('notification must be int, long or Instance'
54 raise Exception('notification must be int or Instance'
55 ' of Notification got %s' % type(notification))
55 ' of Notification got %s' % type(notification))
56
56
57 def create(
57 def create(
General Comments 0
You need to be logged in to leave comments. Login now