Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixing formatting with black (#1271)
- Loading branch information
Showing
32 changed files
with
527 additions
and
390 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,39 @@ | ||
from dateutil.relativedelta import relativedelta | ||
from datetime import datetime, date, timezone | ||
|
||
BASE = datetime.combine(date.today(), datetime.min.time()).replace(day=1, tzinfo=timezone.utc) | ||
BASE = datetime.combine(date.today(), datetime.min.time()).replace( | ||
day=1, tzinfo=timezone.utc | ||
) | ||
|
||
|
||
def _to_timestamp(i): | ||
return int((BASE + relativedelta(months=i)).timestamp()) * 1000 | ||
|
||
|
||
def _generate_timeline(start_range, value_key, to_value, timestamp_key='timestamp'): | ||
return [{timestamp_key: _to_timestamp(i), value_key: to_value(abs(i))} for i in range(start_range, 0)] | ||
|
||
|
||
def generate_installs_timeline(start_range, ts_key='timestamp', to_value=lambda i: 2 if i % 2 == 0 else 0): | ||
return _generate_timeline(start_range=start_range, value_key='installs', to_value=to_value, timestamp_key=ts_key) | ||
|
||
|
||
def generate_commits_timeline(start_range, ts_key='timestamp', to_value=lambda i: i + 5): | ||
return _generate_timeline(start_range=start_range, value_key='commits', to_value=to_value, timestamp_key=ts_key) | ||
def _generate_timeline(start_range, value_key, to_value, timestamp_key="timestamp"): | ||
return [ | ||
{timestamp_key: _to_timestamp(i), value_key: to_value(abs(i))} | ||
for i in range(start_range, 0) | ||
] | ||
|
||
|
||
def generate_installs_timeline( | ||
start_range, ts_key="timestamp", to_value=lambda i: 2 if i % 2 == 0 else 0 | ||
): | ||
return _generate_timeline( | ||
start_range=start_range, | ||
value_key="installs", | ||
to_value=to_value, | ||
timestamp_key=ts_key, | ||
) | ||
|
||
|
||
def generate_commits_timeline( | ||
start_range, ts_key="timestamp", to_value=lambda i: i + 5 | ||
): | ||
return _generate_timeline( | ||
start_range=start_range, | ||
value_key="commits", | ||
to_value=to_value, | ||
timestamp_key=ts_key, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
def script_path_middleware(script_path): | ||
def wrapper(wsgi_app): | ||
|
||
# Allows route mapping to ignore the specific prefix if present | ||
def new_app(environ, start_response): | ||
if environ['PATH_INFO'].startswith(script_path): | ||
environ['PATH_INFO'] = environ['PATH_INFO'][len(script_path):] | ||
environ['SCRIPT_NAME'] += script_path | ||
if environ["PATH_INFO"].startswith(script_path): | ||
environ["PATH_INFO"] = environ["PATH_INFO"][len(script_path) :] | ||
environ["SCRIPT_NAME"] += script_path | ||
return wsgi_app(environ, start_response) | ||
|
||
return new_app | ||
|
||
return wrapper |
Oops, something went wrong.