This is an automated email from the ASF dual-hosted git repository.
brondsem pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/allura.git
The following commit(s) were added to refs/heads/master by this push:
new 2c98a3f54 [#8498] PEP8 cleanup
2c98a3f54 is described below
commit 2c98a3f5471574909880c944b44a02b0872b5b6f
Author: Guillermo Cruz <[email protected]>
AuthorDate: Wed Feb 8 17:11:29 2023 -0600
[#8498] PEP8 cleanup
---
Allura/allura/controllers/auth.py | 25 +++----
Allura/allura/controllers/project.py | 19 +++---
Allura/allura/ext/admin/admin_main.py | 12 ++--
Allura/allura/lib/custom_middleware.py | 21 +++---
Allura/allura/model/auth.py | 16 ++---
Allura/allura/tests/functional/test_admin.py | 17 +++--
Allura/allura/tests/functional/test_auth.py | 35 +++++-----
Allura/allura/tests/functional/test_root.py | 14 ++--
.../allura/tests/functional/test_user_profile.py | 5 +-
Allura/allura/tests/test_tasks.py | 18 ++---
ForgeGit/forgegit/tests/model/test_repository.py | 33 +++++-----
.../forgeimporters/tests/github/test_tracker.py | 2 +-
ForgeWiki/forgewiki/tests/functional/test_root.py | 76 +++++++++++-----------
scripts/teamforge-import.py | 20 +++---
14 files changed, 159 insertions(+), 154 deletions(-)
diff --git a/Allura/allura/controllers/auth.py
b/Allura/allura/controllers/auth.py
index 21b3fc346..c45274556 100644
--- a/Allura/allura/controllers/auth.py
+++ b/Allura/allura/controllers/auth.py
@@ -684,11 +684,8 @@ class PreferencesController(BaseController):
primary_addr,
user=user)
if not admin:
- email_body =
g.jinja2_env.get_template('allura:templates/mail/primary_email_changed.md').render(dict(
- user=user,
- config=config,
- addr=primary_addr
- ))
+ email_body =
g.jinja2_env.get_template('allura:templates/mail/primary_email_changed.md').render(
+ dict(user=user, config=config, addr=primary_addr))
# send to previous primary addr
send_system_mail_to_user(old_primary_addr, 'Primary Email
Address Changed', email_body)
user.set_pref('email_address', primary_addr)
@@ -842,10 +839,8 @@ class PreferencesController(BaseController):
del session['totp_new_key']
session.save()
tg.flash('Two factor authentication has now been set up.')
- email_body =
g.jinja2_env.get_template('allura:templates/mail/twofactor_enabled.md').render(dict(
- user=c.user,
- config=config,
- ))
+ email_body =
g.jinja2_env.get_template('allura:templates/mail/twofactor_enabled.md').render(
+ dict(user=c.user, config=config, ))
send_system_mail_to_user(c.user, 'Two-Factor Authentication
Enabled', email_body)
redirect('/auth/preferences/multifactor_recovery')
@@ -977,7 +972,7 @@ class UserSkillsController(BaseController):
@with_trailing_slash
@expose('jinja:allura:templates/user_skills.html')
def index(self, **kw):
- l = []
+ lst = []
parents = []
if kw.get('selected_category') is not None:
selected_skill = M.TroveCategory.query.get(
@@ -985,12 +980,12 @@ class UserSkillsController(BaseController):
elif self.category:
selected_skill = self.category
else:
- l = M.TroveCategory.query.find(
+ lst = M.TroveCategory.query.find(
dict(trove_parent_id=0, show_as_skill=True)).all()
selected_skill = None
if selected_skill:
- l = [scat for scat in selected_skill.subcategories
- if scat.show_as_skill]
+ lst = [scat for scat in selected_skill.subcategories
+ if scat.show_as_skill]
temp_cat = selected_skill.parent_category
while temp_cat:
parents = [temp_cat] + parents
@@ -998,11 +993,11 @@ class UserSkillsController(BaseController):
provider = plugin.AuthenticationProvider.get(request)
menu = provider.account_navigation()
return dict(
- skills_list=l,
+ skills_list=lst,
selected_skill=selected_skill,
parents=parents,
menu=menu,
- add_details_fields=(len(l) == 0))
+ add_details_fields=(len(lst) == 0))
@expose()
@require_post()
diff --git a/Allura/allura/controllers/project.py
b/Allura/allura/controllers/project.py
index 56d01c9d0..089dc70a2 100644
--- a/Allura/allura/controllers/project.py
+++ b/Allura/allura/controllers/project.py
@@ -111,7 +111,7 @@ class NeighborhoodController:
else:
redirect(c.project.app_configs[0].options.mount_point + '/')
else:
- text=g.markdown.cached_convert(
+ text = g.markdown.cached_convert(
self.neighborhood, 'homepage'),
c.project_summary = W.project_summary
@@ -251,7 +251,7 @@ class NeighborhoodController:
def icon(self, w=None, **kw):
try:
if isinstance(w, list):
- w = w[0]
+ w = w[0]
icon = c.project.icon_sized(w=int(w or 48))
except ValueError as e:
log.info('Invalid project icon size: %s on %s', e, request.url)
@@ -287,7 +287,8 @@ class
NeighborhoodProjectBrowseController(ProjectBrowseController):
def _lookup(self, category_name, *remainder):
c.project = self.neighborhood.neighborhood_project
category_name = unquote(category_name)
- return
NeighborhoodProjectBrowseController(neighborhood=self.neighborhood,
category_name=category_name, parent_category=self.category), remainder
+ return
NeighborhoodProjectBrowseController(neighborhood=self.neighborhood,
category_name=category_name,
+
parent_category=self.category), remainder
@expose('jinja:allura:templates/neighborhood_project_list.html')
@without_trailing_slash
@@ -318,7 +319,7 @@ class ToolListController:
c.page_list = W.page_list
tool_name = tool_name.lower()
entries = c.project.sitemap(included_tools=[tool_name],
- tools_only=True, per_tool_limit=None)
+ tools_only=True, per_tool_limit=None)
total_entries = len(entries)
limit, page = h.paging_sanitizer(limit, page, total_entries)
start = page * limit
@@ -330,7 +331,7 @@ class ToolListController:
entries=entries[start:start + limit],
type=tool_label,
tool_name=h.pluralize_tool_name(tool_label, total_entries),
- )
+ )
class ProjectController(FeedController):
@@ -391,7 +392,8 @@ class ProjectController(FeedController):
developers.append(_user)
else:
users.append(_user)
- get_username = lambda user: user['username']
+
+ def get_username(user): return user['username']
admins = sorted(admins, key=get_username)
developers = sorted(developers, key=get_username)
users = sorted(users, key=get_username)
@@ -407,7 +409,8 @@ class ProjectController(FeedController):
if hasattr(app, 'default_redirect'):
app.default_redirect()
args = dict(redirect_with=exc.HTTPMovedPermanently)
- redirect(app.url() if callable(app.url) else app.url, **args) #
Application has property; Subproject has method
+ # Application has property; Subproject has method
+ redirect(app.url() if callable(app.url) else app.url, **args)
else:
redirect(c.project.app_configs[0].url(),
redirect_with=exc.HTTPMovedPermanently)
@@ -427,7 +430,7 @@ class ProjectController(FeedController):
def icon(self, w=48, **kw):
try:
if isinstance(w, list):
- w = w[0]
+ w = w[0]
icon = c.project.icon_sized(w=int(w))
except ValueError as e:
log.info('Invalid project icon size: %s on %s', e, request.url)
diff --git a/Allura/allura/ext/admin/admin_main.py
b/Allura/allura/ext/admin/admin_main.py
index f02acc200..3cf3eba29 100644
--- a/Allura/allura/ext/admin/admin_main.py
+++ b/Allura/allura/ext/admin/admin_main.py
@@ -54,7 +54,6 @@ from . import widgets as aw
import six
-
log = logging.getLogger(__name__)
@@ -504,6 +503,7 @@ class ProjectAdminController(BaseController):
trove_cat_id=trove_obj.trove_cat_id,
error_msg=error_msg,
in_trove=in_trove)
+
@expose()
@require_post()
def delete_trove(self, type, trove, **kw):
@@ -529,10 +529,12 @@ class ProjectAdminController(BaseController):
c_filename, c_fileext = os.path.splitext(screen.filename)
if c_fileext == '.png' and e_fileext.lower() == '.bmp' and
e_filename == c_filename:
future_bmp = True
- # If both filename(without ext.) equals and exiting file
ext. is png and given file ext is bmp, there will be two similar png files.
+ # If both filename(without ext.) equals and exiting file
ext. is png and given file ext is bmp,
+ # there will be two similar png files.
if screen.filename == screenshot.filename or future_bmp:
- screenshot.filename = re.sub(r'(.*)\.(.*)', r'\1-' +
str(randint(1000,9999)) + r'.\2', screenshot.filename)
+ screenshot.filename = re.sub(r'(.*)\.(.*)', r'\1-' +
str(randint(1000, 9999)) + r'.\2',
+ screenshot.filename)
# if filename already exists append a random number
break
M.AuditLog.log('screenshots: added screenshot {} with caption
"{}"'.format(
@@ -705,7 +707,7 @@ class ProjectAdminController(BaseController):
flash(f'{exc.__class__.__name__}: {exc.args[0]}',
'error')
if request.referer is not None and tool is not None and 'delete' in
tool[0] and \
- re.search(c.project.url() + r'(admin\/|)' +
tool[0]['mount_point']+ r'\/*',
+ re.search(c.project.url() + r'(admin\/|)' + tool[0]['mount_point']
+ r'\/*',
six.ensure_text(request.referer)):
# Redirect to root when deleting currect module
redirect('../')
@@ -1073,7 +1075,7 @@ class PermissionsController(BaseController):
permissions[perm] = role_ids
c.project.acl = []
for perm, role_ids in permissions.items():
- role_names = lambda ids: ','.join(sorted(
+ def role_names(ids): return ','.join(sorted(
pr.name for pr in M.ProjectRole.query.find(dict(_id={'$in':
ids}))))
old_role_ids = old_permissions.get(perm, [])
if old_role_ids != role_ids:
diff --git a/Allura/allura/lib/custom_middleware.py
b/Allura/allura/lib/custom_middleware.py
index 4ea99c6d3..95c9a0122 100644
--- a/Allura/allura/lib/custom_middleware.py
+++ b/Allura/allura/lib/custom_middleware.py
@@ -210,7 +210,8 @@ class CSRFMiddleware:
# Set cookie for use in later forms:
- # in addition to setting a cookie, set this so its available on first
response before cookie gets created in browser
+ # in addition to setting a cookie,
+ # set this so its available on first response before cookie gets
created in browser
environ[self._cookie_name] = cookie
def session_start_response(status, headers, exc_info=None):
@@ -272,6 +273,7 @@ class SetRequestHostFromConfig:
Set request properties for host and port, based on the 'base_url' config
setting.
This permits code to use request.host etc to construct URLs correctly,
even when behind a proxy, like in docker
"""
+
def __init__(self, app, config):
self.app = app
self.config = config
@@ -472,46 +474,43 @@ class ContentSecurityPolicyMiddleware:
report_rules =
set(resp.headers.getall('Content-Security-Policy-Report-Only'))
report_uri = self.config.get('csp.report_uri', None)
report_uri_enforce = self.config.get('csp.report_uri_enforce', None)
-
+
if rules:
resp.headers.pop('Content-Security-Policy')
if report_rules:
- resp.headers.pop('Content-Security-Policy-Report-Only')
-
+ resp.headers.pop('Content-Security-Policy-Report-Only')
if self.config['base_url'].startswith('https'):
rules.add('upgrade-insecure-requests')
-
if self.config.get('csp.frame_sources'):
- if asbool(self.config.get('csp.frame_sources_enforce',False)):
+ if asbool(self.config.get('csp.frame_sources_enforce', False)):
rules.add(f"frame-src {self.config['csp.frame_sources']}")
else:
report_rules.add(f"frame-src
{self.config['csp.frame_sources']}")
if self.config.get('csp.form_action_urls'):
- if asbool(self.config.get('csp.form_actions_enforce',False)):
+ if asbool(self.config.get('csp.form_actions_enforce', False)):
rules.add(f"form-action {self.config['csp.form_action_urls']}")
else:
report_rules.add(f"form-action
{self.config['csp.form_action_urls']}")
if self.config.get('csp.script_src'):
script_srcs = self.config['csp.script_src']
- """
+ """
Sometimes you might have the need to build custom values from
inside a controller and pass it
to the middleware. In this case we pass a custom list of domains
from google that can't be built
directly in here.
"""
- if environ.get('csp_script_domains',''):
+ if environ.get('csp_script_domains', ''):
script_srcs = f"{script_srcs} {'
'.join(environ['csp_script_domains'])}"
- if asbool(self.config.get('csp.script_src_enforce',False)):
+ if asbool(self.config.get('csp.script_src_enforce', False)):
rules.add(f"script-src {script_srcs}
{self.config.get('csp.script_src.extras','')}")
else:
report_rules.add(f"script-src {script_srcs}
{self.config.get('csp.script_src.extras','')}")
-
rules.add("object-src 'none'")
rules.add("frame-ancestors 'self'")
if rules:
diff --git a/Allura/allura/model/auth.py b/Allura/allura/model/auth.py
index 4e3f50e1a..274cac15d 100644
--- a/Allura/allura/model/auth.py
+++ b/Allura/allura/model/auth.py
@@ -177,8 +177,8 @@ please visit the following URL:
%s
''' % (self.email,
- self.claimed_by_user(include_pending=True).username,
- h.absurl(f'/auth/verify_addr?a={h.urlquote(self.nonce)}'),
+ self.claimed_by_user(include_pending=True).username,
+ h.absurl(f'/auth/verify_addr?a={h.urlquote(self.nonce)}'),
)
log.info('Verification email:\n%s', text)
allura.tasks.mail_tasks.sendsimplemail.post(
@@ -425,10 +425,10 @@ class User(MappedClass, ActivityNode, ActivityObject,
SearchIndexable):
def make_password_reset_url(self):
hash = h.nonce(42)
+ expiry_delta =
timedelta(seconds=int(config.get('auth.recovery_hash_expiry_period', 600)))
self.set_tool_data('AuthPasswordReset',
hash=hash,
- hash_expiry=datetime.utcnow() +
-
timedelta(seconds=int(config.get('auth.recovery_hash_expiry_period', 600))))
+ hash_expiry=datetime.utcnow() + expiry_delta)
reset_url = h.absurl(f'/auth/forgotten_password/{hash}')
return reset_url
@@ -638,7 +638,7 @@ class User(MappedClass, ActivityNode, ActivityObject,
SearchIndexable):
private_project = self.private_project()
except Exception:
log.warning('Error getting/creating user-project for %s',
- self.username, exc_info=True)
+ self.username, exc_info=True)
private_project = None
icon_source = None
if private_project and private_project.icon:
@@ -682,7 +682,7 @@ class User(MappedClass, ActivityNode, ActivityObject,
SearchIndexable):
users = [u for u in users if u is not None]
if len(users) > 1:
log.warning('Multiple active users matching confirmed email: %s
%s. '
- 'Using first one', [u.username for u in users], addr)
+ 'Using first one', [u.username for u in users], addr)
return users[0] if len(users) > 0 else None
@classmethod
@@ -980,8 +980,8 @@ class ProjectRole(MappedClass):
@property
def user(self):
if (self.user_id is None
- and self.name
- and self.name != '*anonymous'):
+ and self.name
+ and self.name != '*anonymous'):
return None
return User.query.get(_id=self.user_id)
diff --git a/Allura/allura/tests/functional/test_admin.py
b/Allura/allura/tests/functional/test_admin.py
index 1a1bb251c..2b18d098a 100644
--- a/Allura/allura/tests/functional/test_admin.py
+++ b/Allura/allura/tests/functional/test_admin.py
@@ -957,33 +957,33 @@ class TestProjectAdmin(TestController):
r.mustcontain('Neighborhood Invitation(s) for test')
def test_social_networks(self):
- #Invalid Twitter
- resp = self.app.post('/admin/update',
params={'twitter_handle':'https://twit.com/tests'})
+ # invalid Twitter
+ resp = self.app.post('/admin/update', params={'twitter_handle':
'https://twit.com/tests'})
assert resp.status_int == 200
resp = self.app.post('/admin/update', params={'twitter_handle':
'https://google.com'})
assert resp.status_int == 200
- #invalid Facebook
+ # invalid Facebook
resp = self.app.post('/admin/update', params={'facebook_page':
'https://facebok.com'})
assert resp.status_int == 200
resp = self.app.post('/admin/update', params={'facebook_page':
'https://spam.com'})
assert resp.status_int == 200
assert 'Invalid Facebook address' in resp
- #invalid instagram
+ # invalid instagram
resp = self.app.post('/admin/update', params={'instagram_page':
'https://instagrams.com'})
assert resp.status_int == 200
- #invalid fediverse
+ # invalid fediverse
resp = self.app.post('/admin/update', params={'fediverse_address':
'@test12@indieweb'})
assert resp.status_int == 200
- #valid Twitter
+ # valid Twitter
resp = self.app.post('/admin/update', params={'twitter_handle':
'https://twitter.com/sourceforge'})
assert resp.status_int == 302
resp = self.app.post('/admin/update', params={'twitter_handle':
'@sourceforge'})
assert resp.status_int == 302
- #valid Facebook
+ # valid Facebook
resp = self.app.post('/admin/update', params={'facebook_page':
'https://www.facebook.com/sourceforgenet/'})
assert resp.status_int == 302
- #valid instagram
+ # valid instagram
resp = self.app.post('/admin/update', params={'instagram_page':
'https://instagram.com/test'})
assert resp.status_int == 302
resp = self.app.post('/admin/update', params={'instagram_page':
'@test'})
@@ -995,7 +995,6 @@ class TestProjectAdmin(TestController):
assert resp.status_int == 302
-
class TestExport(TestController):
def setup_method(self, method):
diff --git a/Allura/allura/tests/functional/test_auth.py
b/Allura/allura/tests/functional/test_auth.py
index 06524f366..fc2536678 100644
--- a/Allura/allura/tests/functional/test_auth.py
+++ b/Allura/allura/tests/functional/test_auth.py
@@ -76,8 +76,8 @@ class TestAuth(TestController):
r = self.app.post('/auth/do_login', antispam=True, params=dict(
username='test-user', password='foo', honey1='robot', # bad
honeypot value
_session_id=self.app.cookies['_session_id']),
-
extra_environ={'regular_antispam_err_handling_even_when_tests': 'true'},
- status=302)
+ extra_environ={'regular_antispam_err_handling_even_when_tests':
'true'},
+ status=302)
wf = json.loads(self.webflash(r))
assert wf['status'] == 'error'
assert wf['message'] == 'Spambot protection engaged'
@@ -681,7 +681,7 @@ class TestAuth(TestController):
assert '[email protected]' not in r
assert '[email protected]' in r
assert
(M.User.query.get(username='test-admin').get_pref('email_address') ==
- '[email protected]')
+ '[email protected]')
# add test@example
with td.audits('New email address: [email protected]', user=True):
@@ -932,8 +932,8 @@ class TestAuth(TestController):
_session_id=self.app.cookies['_session_id']))
assert 'Enter a value 6 characters long or more' in r
assert ('Usernames must include only small letters, numbers, '
- 'and dashes. They must also start with a letter and be '
- 'at least 3 characters long.' in r)
+ 'and dashes. They must also start with a letter and be '
+ 'at least 3 characters long.' in r)
r = self.app.post(
'/auth/save_new',
params=dict(
@@ -1264,7 +1264,6 @@ class TestPreferences(TestController):
user = M.User.query.get(username='test-admin')
assert len(user.socialnetworks) == 0
-
@td.with_user_project('test-admin')
def test_contacts(self):
# Add skype account
@@ -1321,8 +1320,8 @@ class TestPreferences(TestController):
user = M.User.query.get(username='test-admin')
assert len(user.socialnetworks) == 2
expected = [{'socialnetwork': socialnetwork2, 'accounturl':
accounturl2},
- {'socialnetwork': socialnetwork3, 'accounturl': accounturl3}]
- assert all([social in expected for social in user.socialnetworks])
+ {'socialnetwork': socialnetwork3, 'accounturl':
accounturl3}]
+ assert all([social in expected for social in user.socialnetworks])
# Add empty social network account
self.app.post('/auth/user_info/contacts/add_social_network',
@@ -1332,7 +1331,7 @@ class TestPreferences(TestController):
user = M.User.query.get(username='test-admin')
assert len(user.socialnetworks) == 2
expected = [{'socialnetwork': socialnetwork2, 'accounturl':
accounturl2},
- {'socialnetwork': socialnetwork3, 'accounturl': accounturl3}]
+ {'socialnetwork': socialnetwork3, 'accounturl':
accounturl3}]
assert all([social in expected for social in user.socialnetworks])
# Add invalid social network account
@@ -1343,7 +1342,7 @@ class TestPreferences(TestController):
user = M.User.query.get(username='test-admin')
assert len(user.socialnetworks) == 2
expected = [{'socialnetwork': socialnetwork2, 'accounturl':
accounturl2},
- {'socialnetwork': socialnetwork3, 'accounturl': accounturl3}]
+ {'socialnetwork': socialnetwork3, 'accounturl':
accounturl3}]
assert all([social in expected for social in user.socialnetworks])
# Add telephone number
@@ -2045,7 +2044,8 @@ class TestOAuth(TestController):
)
ThreadLocalODMSession.flush_all()
r = self.app.post('/rest/oauth/do_authorize', params={'yes': '1',
'oauth_token': 'api_key_reqtok_12345'})
- assert
r.location.startswith('http://my.domain.com/callback?myparam=foo&oauth_token=api_key_reqtok_12345&oauth_verifier=')
+ url =
'http://my.domain.com/callback?myparam=foo&oauth_token=api_key_reqtok_12345&oauth_verifier='
+ assert r.location.startswith(url)
class TestOAuthRequestToken(TestController):
@@ -2197,7 +2197,7 @@ class TestDisableAccount(TestController):
extra_environ={'username': '*anonymous'})
assert r.status_int == 302
assert (r.location ==
- 'http://localhost/auth/?return_to=%2Fauth%2Fdisable%2F')
+ 'http://localhost/auth/?return_to=%2Fauth%2Fdisable%2F')
def test_lists_user_projects(self):
r = self.app.get('/auth/disable/')
@@ -2565,7 +2565,8 @@ class TestTwoFactor(TestController):
form['code'] = code
with audits('Set up multifactor TOTP', user=True):
r = form.submit()
- assert 'Two factor authentication has now been set up.' ==
json.loads(self.webflash(r))['message'], self.webflash(r)
+ msg = 'Two factor authentication has now been set up.'
+ assert msg == json.loads(self.webflash(r))['message'],
self.webflash(r)
tasks =
M.MonQTask.query.find(dict(task_name='allura.tasks.mail_tasks.sendsimplemail')).all()
assert len(tasks) == 1
@@ -2615,7 +2616,8 @@ class TestTwoFactor(TestController):
form = r.forms['totp_set']
form['code'] = code
r = form.submit()
- assert 'Two factor authentication has now been set up.' ==
json.loads(self.webflash(r))['message'], self.webflash(r)
+ msg = 'Two factor authentication has now been set up.'
+ assert msg == json.loads(self.webflash(r))['message'], self.webflash(r)
# new key in place
current_key =
TotpService.get().get_secret_key(M.User.query.get(username='test-admin'))
@@ -2641,7 +2643,8 @@ class TestTwoFactor(TestController):
r.form['password'] = 'foo'
with audits('Disabled multifactor TOTP', user=True):
r = r.form.submit()
- assert 'Multifactor authentication has now been disabled.' ==
json.loads(self.webflash(r))['message'], self.webflash(r)
+ msg = 'Multifactor authentication has now been disabled.'
+ assert msg == json.loads(self.webflash(r))['message'],
self.webflash(r)
user = M.User.query.get(username='test-admin')
assert user.get_pref('multifactor') is False
assert TotpService().get().get_secret_key(user) is None
@@ -2746,7 +2749,7 @@ class TestTwoFactor(TestController):
# sent back to regular login
assert ('Your multifactor login was disrupted, please start over.' ==
- json.loads(self.webflash(r))['message']), self.webflash(r)
+ json.loads(self.webflash(r))['message']), self.webflash(r)
r = r.follow()
assert 'Password Login' in r
diff --git a/Allura/allura/tests/functional/test_root.py
b/Allura/allura/tests/functional/test_root.py
index d795187ae..1feaa3b63 100644
--- a/Allura/allura/tests/functional/test_root.py
+++ b/Allura/allura/tests/functional/test_root.py
@@ -62,7 +62,7 @@ class TestRootController(TestController):
def test_neighborhood(self):
response = self.app.get('/neighborhood')
assert response.html.find('h2', {'class': 'dark
title'}).find('span').contents[
- 0].strip() == 'All Neighborhoods'
+ 0].strip() == 'All Neighborhoods'
nbhds = response.html.findAll('div', {'class': 'nbhd_name'})
assert nbhds[0].find('a').get('href') == '/adobe/'
cat_links = response.html.find('div', {'id': 'sidebar'}).findAll('li')
@@ -177,8 +177,7 @@ class TestRootController(TestController):
callable_name.return_value = 'foo'
self.app.get('/p/')
arg = callable_name.call_args[0][0]
- assert (arg.__wrapped__ ==
- NeighborhoodController.index.__wrapped__)
+ assert arg.__wrapped__ == NeighborhoodController.index.__wrapped__
set_transaction_name.assert_called_with('foo', priority=2)
def test_error_page(self):
@@ -186,8 +185,8 @@ class TestRootController(TestController):
r = self.app.get('/error/document')
r.mustcontain("We're sorry but we weren't able to process")
- @mock.patch.dict(tg.config, {'csp.frame_sources_enforce': True, \
- 'csp.report_uri_enforce':
'https://example.com/r/d/csp/enforce', \
+ @mock.patch.dict(tg.config, {'csp.frame_sources_enforce': True,
+ 'csp.report_uri_enforce':
'https://example.com/r/d/csp/enforce',
'csp.form_actions_enforce': True,
'csp.script_src_enforce': True})
def test_headers(self):
@@ -213,8 +212,8 @@ class TestRootController(TestController):
csp_headers =
resp.headers.getall('Content-Security-Policy-Report-Only')[0]
assert all([h.strip() in csp_headers for h in
expected_headers.split(';')])
-
- @mock.patch.dict(tg.config, {'csp.report_uri_enforce':
'https://example.com/r/d/csp/enforce', 'csp.frame_sources_enforce': True})
+ @mock.patch.dict(tg.config, {'csp.report_uri_enforce':
'https://example.com/r/d/csp/enforce',
+ 'csp.frame_sources_enforce': True})
def test_headers_frame_sources_enforce(self):
resp = self.app.get('/p/wiki/Home/')
expected_headers = "report-uri https://example.com/r/d/csp/enforce;"
@@ -226,6 +225,7 @@ class TestRootController(TestController):
assert all([h.strip() in csp_headers for h in
expected_headers.split(';')])
assert all([h.strip() in csp_report_headers for h in
expected_report_headers.split(';')])
+
class TestRootWithSSLPattern(TestController):
def setup_method(self, method):
with td.patch_middleware_config({'force_ssl.pattern': '^/auth'}):
diff --git a/Allura/allura/tests/functional/test_user_profile.py
b/Allura/allura/tests/functional/test_user_profile.py
index 9d9e205fb..e6de739d1 100644
--- a/Allura/allura/tests/functional/test_user_profile.py
+++ b/Allura/allura/tests/functional/test_user_profile.py
@@ -24,6 +24,7 @@ from allura.tests import decorators as td
from allura.tests import TestController
from allura.tests.functional.test_discuss import TestDiscussBase
+
class TestUserProfileSections(TestController):
def teardown_method(self, method):
@@ -70,7 +71,7 @@ class TestUserProfile(TestDiscussBase):
def test_profile(self):
r = self.app.get('/u/test-admin/profile/')
assert ('Test Admin' ==
- r.html.find('h1', 'project_title').find('a').text)
+ r.html.find('h1', 'project_title').find('a').text)
sections = {c for s in r.html.findAll(None, 'profile-section') for c
in s['class']}
assert 'personal-data' in sections
assert 'Username:\ntest-admin' in r.html.find(None,
'personal-data').getText().replace(' ', '')
@@ -85,7 +86,7 @@ class TestUserProfile(TestDiscussBase):
@mock.patch.dict(tg.config, {'use_gravatar': 'true'})
def test_profile_user_card(self):
user = User.by_username('test-admin')
- locals = {
+ locals = {
'city': 'test-city',
'country': 'US'
}
diff --git a/Allura/allura/tests/test_tasks.py
b/Allura/allura/tests/test_tasks.py
index f4521caad..10baaceca 100644
--- a/Allura/allura/tests/test_tasks.py
+++ b/Allura/allura/tests/test_tasks.py
@@ -73,7 +73,8 @@ class TestRepoTasks(unittest.TestCase):
@mock.patch.object(M, 'MergeRequest')
def test_merge(self, MR, session):
mr = mock.Mock(_id='_id', activity_name='merge req',
activity_url='/fake/url', activity_extras={}, node_id=None,
- app=mock.Mock(activity_name='code merge',
activity_url='/fake/url', activity_extras={}, node_id=None))
+ app=mock.Mock(activity_name='code merge',
activity_url='/fake/url', activity_extras={},
+ node_id=None))
MR.query.get.return_value = mr
repo_tasks.merge(mr._id)
mr.app.repo.merge.assert_called_once_with(mr)
@@ -143,12 +144,12 @@ class TestEventTasks(unittest.TestCase):
def test_compound_error(self):
t = raise_compound_exception.post()
- with LogCapture(level=logging.ERROR) as l, \
+ with LogCapture(level=logging.ERROR) as lc, \
mock.patch.dict(tg.config, {'monq.raise_errors': False}): #
match normal non-test behavior
t()
- # l.check() would be nice, but string is too detailed to check
- assert l.records[0].name == 'allura.model.monq_model'
- msg = l.records[0].getMessage()
+ # lc.check() would be nice, but string is too detailed to check
+ assert lc.records[0].name == 'allura.model.monq_model'
+ msg = lc.records[0].getMessage()
assert "AssertionError('assert 0'" in msg
assert "AssertionError('assert 5'" in msg
assert ' on job <MonQTask ' in msg
@@ -210,7 +211,7 @@ class TestIndexTasks(unittest.TestCase):
t3 = _TestArtifact.query.get(_shorthand_id='t3')
assert len(t3.backrefs) == 5, t3.backrefs
assert (find_slinks.call_args_list ==
- [mock.call(a.index().get('text')) for a in artifacts])
+ [mock.call(a.index().get('text')) for a in artifacts])
@td.with_wiki
@mock.patch('allura.tasks.index_tasks.g.solr')
@@ -560,7 +561,7 @@ class TestUserNotificationTasks(TestController):
dict(task_name='allura.tasks.mail_tasks.sendsimplemail')).all()
assert len(tasks) == 1
assert (tasks[0].kwargs['subject'] ==
- '[test:wiki] Your name was mentioned')
+ '[test:wiki] Your name was mentioned')
assert tasks[0].kwargs['toaddr'] == '[email protected]'
assert tasks[0].kwargs['reply_to'] == g.noreply
text = tasks[0].kwargs['text']
@@ -644,7 +645,7 @@ class TestExportTasks(unittest.TestCase):
dict(task_name='allura.tasks.mail_tasks.sendsimplemail')).all()
assert len(tasks) == 1
assert (tasks[0].kwargs['subject'] ==
- 'Bulk export for project test completed')
+ 'Bulk export for project test completed')
assert tasks[0].kwargs['fromaddr'] == '"Allura" <noreply@localhost>'
assert tasks[0].kwargs['reply_to'] == g.noreply
text = tasks[0].kwargs['text']
@@ -663,4 +664,5 @@ class TestAdminTasks(unittest.TestCase):
def test_install_app_docstring(self):
assert 'ep_name, mount_point=None' in admin_tasks.install_app.__doc__
+
Mapper.compile_all()
diff --git a/ForgeGit/forgegit/tests/model/test_repository.py
b/ForgeGit/forgegit/tests/model/test_repository.py
index 7b7468991..0dd8a9fc0 100644
--- a/ForgeGit/forgegit/tests/model/test_repository.py
+++ b/ForgeGit/forgegit/tests/model/test_repository.py
@@ -485,11 +485,12 @@ By Dave Brondsema''' in text_body
self._setup_weird_chars_repo()
# commits aren't artifacts :/ but still can do some references with
them
# commit b85dfbe message mentions
[616d24f8dd4e95cadd8e93df5061f09855d1a066]
- ref =
M.ArtifactReference.query.get(_id='allura.model.repository.Commit#616d24f8dd4e95cadd8e93df5061f09855d1a066')
+ id =
'allura.model.repository.Commit#616d24f8dd4e95cadd8e93df5061f09855d1a066'
+ ref = M.ArtifactReference.query.get(_id=id)
assert ref
assert 'b85dfbe' in ref.references[0], ref.references
-
- otherway =
M.ArtifactReference.query.get(_id='allura.model.repository.Commit#b85dfbec3a5d08677bdd402fc0338934f623a234')
+ id =
'allura.model.repository.Commit#b85dfbec3a5d08677bdd402fc0338934f623a234'
+ otherway = M.ArtifactReference.query.get(_id=id)
assert otherway
assert not otherway.references
@@ -499,9 +500,9 @@ By Dave Brondsema''' in text_body
os.remove(
os.path.join(tmpdir,
"git/t/te/test/testgit.git/test-src-git-HEAD.zip"))
assert (self.repo.tarball_path ==
- os.path.join(tmpdir, 'git/t/te/test/testgit.git'))
+ os.path.join(tmpdir, 'git/t/te/test/testgit.git'))
assert (self.repo.tarball_url('HEAD') ==
- 'file:///git/t/te/test/testgit.git/test-src-git-HEAD.zip')
+ 'file:///git/t/te/test/testgit.git/test-src-git-HEAD.zip')
self.repo.tarball('HEAD')
assert os.path.isfile(
os.path.join(tmpdir,
"git/t/te/test/testgit.git/test-src-git-HEAD.zip"))
@@ -606,14 +607,14 @@ By Dave Brondsema''' in text_body
def test_default_branch_non_standard_unset(self):
with mock.patch.object(self.repo, 'get_branches') as gb,\
- mock.patch.object(self.repo, 'set_default_branch') as set_db:
+ mock.patch.object(self.repo, 'set_default_branch') as set_db:
gb.return_value = [Object(name='foo')]
assert self.repo.get_default_branch(('main', 'master')) == 'foo'
set_db.assert_called_once_with('foo')
def test_default_branch_non_standard_invalid(self):
with mock.patch.object(self.repo, 'get_branches') as gb,\
- mock.patch.object(self.repo, 'set_default_branch') as set_db:
+ mock.patch.object(self.repo, 'set_default_branch') as set_db:
self.repo.default_branch_name = 'zz'
gb.return_value = [Object(name='foo')]
assert self.repo.get_default_branch(('main', 'master')) == 'foo'
@@ -621,7 +622,7 @@ By Dave Brondsema''' in text_body
def test_default_branch_invalid(self):
with mock.patch.object(self.repo, 'get_branches') as gb,\
- mock.patch.object(self.repo, 'set_default_branch') as set_db:
+ mock.patch.object(self.repo, 'set_default_branch') as set_db:
self.repo.default_branch_name = 'zz'
gb.return_value = [Object(name='foo'), Object(name='master')]
assert self.repo.get_default_branch(('main', 'master')) == 'master'
@@ -641,7 +642,7 @@ By Dave Brondsema''' in text_body
def test_default_branch_main_before_master(self):
with mock.patch.object(self.repo, 'get_branches') as gb,\
- mock.patch.object(self.repo, 'set_default_branch') as set_db:
+ mock.patch.object(self.repo, 'set_default_branch') as set_db:
self.repo.default_branch_name = None
gb.return_value = [Object(name='master'), Object(name='main')]
assert self.repo.get_default_branch(('main', 'master')) == 'main'
@@ -739,12 +740,12 @@ By Dave Brondsema''' in text_body
@mock.patch('forgegit.model.git_repo.shutil', autospec=True)
def test_merge(self, shutil, GitImplementation, git, tempfile):
mr = mock.Mock(downstream_repo=mock.Mock(
- full_fs_path='downstream-url',
- url=lambda: 'downstream-repo-url'),
- source_branch='source-branch',
- target_branch='target-branch',
- url=lambda: '/merge-request/1/',
- downstream=mock.Mock(commit_id='cid'))
+ full_fs_path='downstream-url',
+ url=lambda: 'downstream-repo-url'),
+ source_branch='source-branch',
+ target_branch='target-branch',
+ url=lambda: '/merge-request/1/',
+ downstream=mock.Mock(commit_id='cid'))
_git = mock.Mock()
self.repo._impl._git.git = _git
self.repo.merge(mr)
@@ -1004,7 +1005,7 @@ class TestGitImplementation(unittest.TestCase):
'forgegit', 'tests/data/testrename.git')
repo = mock.Mock(full_fs_path=repo_dir)
impl = GM.git_repo.GitImplementation(repo)
- lcd = lambda c, p: impl.last_commit_ids(mock.Mock(_id=c), p)
+ def lcd(c, p): return impl.last_commit_ids(mock.Mock(_id=c), p)
self.assertEqual(lcd('13951944969cf45a701bf90f83647b309815e6d5',
['f2.txt', 'f3.txt']), {
'f2.txt': '259c77dd6ee0e6091d11e429b56c44ccbf1e64a3',
'f3.txt': '653667b582ef2950c1954a0c7e1e8797b19d778a',
diff --git a/ForgeImporters/forgeimporters/tests/github/test_tracker.py
b/ForgeImporters/forgeimporters/tests/github/test_tracker.py
index e26894ac3..15c575c75 100644
--- a/ForgeImporters/forgeimporters/tests/github/test_tracker.py
+++ b/ForgeImporters/forgeimporters/tests/github/test_tracker.py
@@ -127,7 +127,7 @@ class TestTrackerImporter(TestCase):
{'name': 'first', 'due_date':
'2015-04-23', 'complete': False},
{'name': 'second', 'due_date':
- '2015-04-25', 'complete': False},
+ '2015-04-25', 'complete': False},
],
},
])
diff --git a/ForgeWiki/forgewiki/tests/functional/test_root.py
b/ForgeWiki/forgewiki/tests/functional/test_root.py
index a4c0b0311..6459c853c 100644
--- a/ForgeWiki/forgewiki/tests/functional/test_root.py
+++ b/ForgeWiki/forgewiki/tests/functional/test_root.py
@@ -186,9 +186,9 @@ class TestRootController(TestController):
'title': 'foo',
'text': 'sometext',
'labels': 'test label',
- }).follow()
+ }).follow()
assert ('<a href="/p/test/wiki/search/?q=labels_t:%22test
label%22&parser=standard">test label (1)</a>' in
- response)
+ response)
def test_title_slashes(self):
# forward slash not allowed in wiki page title - converted to dash
@@ -198,7 +198,7 @@ class TestRootController(TestController):
'title': 'foo/bar',
'text': 'sometext',
'labels': '',
- }).follow()
+ }).follow()
assert 'foo-bar' in response
assert 'foo-bar' in response.request.url
@@ -209,7 +209,7 @@ class TestRootController(TestController):
'title': 'page.dot',
'text': 'text1',
'labels': '',
- }).follow()
+ }).follow()
assert 'page.dot' in r
def test_subpage_attempt(self):
@@ -220,7 +220,7 @@ class TestRootController(TestController):
'title': 'tést'.encode(),
'text': 'text1',
'labels': '',
- })
+ })
assert '/p/test/wiki/Home/' in
self.app.get(h.urlquote('/wiki/tést/Home/'))
self.app.get(h.urlquote('/wiki/tést/notthere/'), status=404)
@@ -232,14 +232,14 @@ class TestRootController(TestController):
'title': 'tést'.encode(),
'text': 'text1',
'labels': '',
- })
+ })
self.app.post(
h.urlquote('/wiki/tést/update'),
params={
'title': 'tést'.encode(),
'text': 'text2',
'labels': '',
- })
+ })
response = self.app.get(h.urlquote('/wiki/tést/history'))
assert 'tést' in response
# two revisions are shown
@@ -269,7 +269,7 @@ class TestRootController(TestController):
'title': 'tést'.encode(),
'text': 'sometext',
'labels': '',
- })
+ })
self.app.post(h.urlquote('/wiki/tést/revert'),
params=dict(version='1'))
response = self.app.get(h.urlquote('/wiki/tést/diff') + '?v1=0&v2=0')
assert 'tést' in response
@@ -347,14 +347,14 @@ class TestRootController(TestController):
self.app.post('/wiki/testdiff/update', params=d)
response = self.app.get('/wiki/testdiff/diff?v1=1&v2=2')
assert ('# Now fix <del> permissons. </del> <ins> permissions. </ins> '
- 'Wrong permissions may cause <ins> a </ins> massive
slowdown!' in
- response)
+ 'Wrong permissions may cause <ins> a </ins> massive slowdown!'
in
+ response)
assert '<script>alert' not in response
assert '<script>alert' in response
response = self.app.get('/wiki/testdiff/diff?v1=2&v2=1')
assert ('# Now fix <del> permissions. </del> <ins> permissons. </ins> '
- 'Wrong permissions may cause <del> a </del> massive
slowdown!' in
- response)
+ 'Wrong permissions may cause <del> a </del> massive slowdown!'
in
+ response)
def test_page_raw(self):
self.app.post(
@@ -363,7 +363,7 @@ class TestRootController(TestController):
'title': 'TEST',
'text': 'sometext',
'labels': '',
- })
+ })
response = self.app.get('/wiki/TEST/raw')
assert 'TEST' in response
@@ -374,7 +374,7 @@ class TestRootController(TestController):
'title': 'tést'.encode(),
'text': '',
'labels': '',
- })
+ })
response = self.app.post(h.urlquote('/wiki/tést/revert'),
params=dict(version='1'))
assert '.' in response.json['location']
response = self.app.get(h.urlquote('/wiki/tést/'))
@@ -388,7 +388,7 @@ class TestRootController(TestController):
'title': 'tést'.encode(),
'text': 'sometext',
'labels': '',
- })
+ })
response = self.app.post(h.urlquote('/wiki/tést/revert'),
params=dict(version='1'))
assert '.' in response.json['location']
response = self.app.get(h.urlquote('/wiki/tést/'))
@@ -403,7 +403,7 @@ class TestRootController(TestController):
'title': 'tést'.encode(),
'text': 'sometext',
'labels': '',
- })
+ })
assert spam_checker.check.call_args[0][0] == 'tést\nsometext'
assert response.location == 'http://localhost/wiki/t%C3%A9st/'
@@ -414,7 +414,7 @@ class TestRootController(TestController):
'title': 'tést'.encode(),
'text': '- [ ] checkbox',
'labels': '',
- })
+ })
response = self.app.get(h.urlquote('/wiki/tést/get_markdown'))
assert '- [ ] checkbox' in response
@@ -425,7 +425,7 @@ class TestRootController(TestController):
'title': 'tést'.encode(),
'text': '- [ ] checkbox',
'labels': '',
- })
+ })
response = self.app.post(
h.urlquote('/wiki/tést/update_markdown'),
params={
@@ -448,7 +448,7 @@ class TestRootController(TestController):
'title': 'tést'.encode(),
'text': 'sometext',
'labels': 'yellow,green',
- })
+ })
assert response.location == 'http://localhost/wiki/t%C3%A9st/'
response = self.app.post(
h.urlquote('/wiki/tést/update'),
@@ -456,7 +456,7 @@ class TestRootController(TestController):
'title': 'tést'.encode(),
'text': 'sometext',
'labels': 'yellow',
- })
+ })
assert response.location == 'http://localhost/wiki/t%C3%A9st/'
def test_page_label_count(self):
@@ -469,7 +469,7 @@ class TestRootController(TestController):
'title': 'tést'.encode(),
'text': 'sometext',
'labels': labels,
- })
+ })
r = self.app.get('/wiki/browse_tags/')
assert 'results of 100 ' in r
assert '<div class="page_list">' in r
@@ -502,7 +502,7 @@ class TestRootController(TestController):
'title': 'tést'.encode(),
'text': 'sometext',
'labels': '',
- })
+ })
content = open(__file__, 'rb').read()
self.app.post(h.urlquote('/wiki/tést/attach'),
upload_files=[('file_info', 'test_root.py', content)])
@@ -516,7 +516,7 @@ class TestRootController(TestController):
'title': 'tést'.encode(),
'text': 'sometext',
'labels': '',
- })
+ })
content = open(__file__, 'rb').read()
self.app.post(h.urlquote('/wiki/tést/attach'),
upload_files=[('file_info', 'test1.py', content),
('file_info', 'test2.py', content)])
@@ -531,7 +531,7 @@ class TestRootController(TestController):
'title': 'tést'.encode(),
'text': 'sometext',
'labels': '',
- })
+ })
file_name = 'test_root.py'
file_data = open(__file__, 'rb').read()
upload = ('file_info', file_name, file_data)
@@ -545,7 +545,7 @@ class TestRootController(TestController):
'title': 'TEST',
'text': 'sometext',
'labels': '',
- })
+ })
file_name = 'neo-icon-set-454545-256x350.png'
file_path = os.path.join(
allura.__path__[0], 'nf', 'allura', 'images', file_name)
@@ -584,17 +584,17 @@ class TestRootController(TestController):
'title': 'TEST',
'text': 'sometext',
'labels': '',
- })
+ })
self.app.post('/wiki/aaa/update', params={
'title': 'aaa',
'text': '',
'labels': '',
- })
+ })
self.app.post('/wiki/bbb/update', params={
'title': 'bbb',
'text': '',
'labels': '',
- })
+ })
h.set_context('test', 'wiki', neighborhood='Projects')
a = model.Page.query.find(dict(title='aaa')).first()
@@ -616,7 +616,7 @@ class TestRootController(TestController):
'title': 'tést'.encode(),
'text': 'sometext',
'labels': '',
- })
+ })
wiki_page = self.app.get(h.urlquote('/wiki/tést/'))
assert wiki_page.html.find('div', {'id': 'new_post_holder'})
options_admin = self.app.get(
@@ -635,7 +635,7 @@ class TestRootController(TestController):
'title': 'tést'.encode(),
'text': 'sometext',
'labels': '',
- })
+ })
wiki_page = self.app.get(h.urlquote('/wiki/tést/'))
assert wiki_page.html.find('ul', {'class': 'sidebarmenu'})
options_admin = self.app.get(
@@ -657,7 +657,7 @@ class TestRootController(TestController):
'title': 'tést'.encode(),
'text': 'sometext',
'labels': '',
- })
+ })
wiki_page = self.app.get(h.urlquote('/wiki/tést/'))
assert wiki_page.html.find('div', {'class': 'editbox'})
options_admin = self.app.get(
@@ -676,7 +676,7 @@ class TestRootController(TestController):
'title': 'our_néw_home'.encode(),
'text': 'sometext',
'labels': '',
- })
+ })
homepage_admin = self.app.get('/admin/wiki/home', validate_chunk=True)
assert homepage_admin.form['new_home'].value == 'Home'
homepage_admin.form['new_home'].value = 'our_néw_home'
@@ -702,7 +702,7 @@ class TestRootController(TestController):
'title': 'space page',
'text': '''There is a space in the title!''',
'labels': '',
- }
+ }
self.app.post('/wiki/space%20page/update', params=params)
self.app.get('/wiki/TEST/')
params = {
@@ -720,7 +720,7 @@ class TestRootController(TestController):
* Here is a link to [attach](TEST/attachment/test_root.py)
''',
'labels': '',
- }
+ }
self.app.post('/wiki/TEST/update', params=params)
content = open(__file__, 'rb').read()
self.app.post('/wiki/TEST/attach',
@@ -778,7 +778,7 @@ class TestRootController(TestController):
'title': 'cache',
'text': html,
'labels': '',
- })
+ })
# first request caches html, second serves from cache
r = self.app.get('/wiki/cache/')
r = self.app.get('/wiki/cache/')
@@ -789,12 +789,12 @@ class TestRootController(TestController):
'title': 'aaa',
'text': '111',
'labels': '',
- })
+ })
self.app.post('/wiki/bbb/update', params={
'title': 'bbb',
'text': '222',
'labels': '',
- })
+ })
response = self.app.get('/wiki/browse_pages/')
assert 'aaa' in response
assert 'bbb' in response
@@ -827,7 +827,7 @@ class TestRootController(TestController):
* Handmaid mailto <a href="mailto:[email protected]">Email Yoda</a>
''',
'labels': '',
- }
+ }
self.app.post('/wiki/test_mailto/update', params=params)
r = self.app.get('/wiki/test_mailto/')
mailto_links = 0
diff --git a/scripts/teamforge-import.py b/scripts/teamforge-import.py
index 903232477..ff72c8398 100644
--- a/scripts/teamforge-import.py
+++ b/scripts/teamforge-import.py
@@ -191,7 +191,7 @@ def save_user(usernames):
users[username] = Object(user_data)
if users[username].status != 'Active':
log.warning('user: %s status: %s' %
- (username, users[username].status))
+ (username, users[username].status))
def get_project(project):
@@ -638,19 +638,19 @@ def check_unsupported_tools(project):
doc_count += 1
if doc_count:
log.warning('Migrating documents is not supported, but found %s docs' %
- doc_count)
+ doc_count)
scm = make_client(options.api_url, 'ScmApp')
for repo in scm.service.getRepositoryList(s, project.id).dataRows:
log.warning('Migrating SCM repos is not supported, but found %s' %
- repo.repositoryPath)
+ repo.repositoryPath)
tasks = make_client(options.api_url, 'TaskApp')
task_count = len(
tasks.service.getTaskList(s, project.id, filters=None).dataRows)
if task_count:
log.warning('Migrating tasks is not supported, but found %s tasks' %
- task_count)
+ task_count)
tracker = make_client(options.api_url, 'TrackerApp')
tracker_count = len(
@@ -707,16 +707,13 @@ def download_file(tool, url_path, *filepaths):
# log in to make sure the file should really be html
if resp.headers.type == 'text/html':
# log in and save the file
- resp = loggedInOpener.open(scheme + '://' + hostname +
"/sf/sfmain/do/login", six.moves.urllib.parse.urlencode({
- 'username': options.username,
- 'password': options.password,
- 'returnToUrl': url,
- 'sfsubmit': 'submit'
- }))
+ resp = loggedInOpener.open(scheme + '://' + hostname +
"/sf/sfmain/do/login", six.moves.urllib.parse.urlencode(
+ {'username': options.username, 'password': options.password,
'returnToUrl': url, 'sfsubmit': 'submit'}))
with open(out_file, 'w', encoding='utf-8') as out:
out.write(resp.fp.read())
return out_file
+
bracket_macro = re.compile(r'\[(.*?)\]')
h1 = re.compile(r'^!!!', re.MULTILINE)
h2 = re.compile(r'^!!', re.MULTILINE)
@@ -754,6 +751,7 @@ def wiki2markdown(markup):
markup = re_stats.sub('', markup)
return markup
+
re_rel = re.compile(r'\b(rel\d+)\b')
@@ -1023,6 +1021,7 @@ def get_parser(defaults):
return optparser
+
re_username = re.compile(r"^[a-z\-0-9]+$")
@@ -1060,6 +1059,7 @@ def make_valid_sf_username(orig_username):
sf_username = adjusted_username
return sf_username
+
if __name__ == '__main__':
logging.basicConfig(level=logging.WARN)
log.setLevel(logging.DEBUG)