commit
stringlengths 40
40
| old_file
stringlengths 4
264
| new_file
stringlengths 4
264
| old_contents
stringlengths 0
3.26k
| new_contents
stringlengths 1
4.43k
| subject
stringlengths 15
624
| message
stringlengths 15
4.7k
| lang
stringclasses 3
values | license
stringclasses 13
values | repos
stringlengths 5
91.5k
|
---|---|---|---|---|---|---|---|---|---|
d42b9da06d5cde89a6116d711fc6ae216256cabc | shell/view/home/IconLayout.py | shell/view/home/IconLayout.py | import random
class IconLayout:
def __init__(self, width, height):
self._icons = []
self._width = width
self._height = height
def add_icon(self, icon):
self._icons.append(icon)
self._layout_icon(icon)
def remove_icon(self, icon):
self._icons.remove(icon)
def _is_valid_position(self, icon, x, y):
icon_size = icon.props.size
border = 20
if not (border < x < self._width - icon_size - border and \
border < y < self._height - icon_size - border):
return False
return True
def _layout_icon(self, icon):
while True:
x = random.random() * self._width
y = random.random() * self._height
if self._is_valid_position(icon, x, y):
break
icon.props.x = x
icon.props.y = y
| import random
class IconLayout:
def __init__(self, width, height):
self._icons = []
self._width = width
self._height = height
def add_icon(self, icon):
self._icons.append(icon)
self._layout_icon(icon)
def remove_icon(self, icon):
self._icons.remove(icon)
def _is_valid_position(self, icon, x, y):
icon_size = icon.get_property('size')
border = 20
if not (border < x < self._width - icon_size - border and \
border < y < self._height - icon_size - border):
return False
return True
def _layout_icon(self, icon):
while True:
x = random.random() * self._width
y = random.random() * self._height
if self._is_valid_position(icon, x, y):
break
icon.set_property('x', x)
icon.set_property('y', y)
| Use get/set_property rather than direct accessors | Use get/set_property rather than direct accessors
| Python | lgpl-2.1 | Daksh/sugar-toolkit-gtk3,manuq/sugar-toolkit-gtk3,tchx84/sugar-toolkit-gtk3,quozl/sugar-toolkit-gtk3,tchx84/sugar-toolkit-gtk3,i5o/sugar-toolkit-gtk3,puneetgkaur/backup_sugar_sugartoolkit,quozl/sugar-toolkit-gtk3,godiard/sugar-toolkit-gtk3,tchx84/debian-pkg-sugar-toolkit,tchx84/debian-pkg-sugar-toolkit,ceibal-tatu/sugar-toolkit,gusDuarte/sugar-toolkit-gtk3,tchx84/debian-pkg-sugar-toolkit,tchx84/debian-pkg-sugar-toolkit-gtk3,tchx84/debian-pkg-sugar-toolkit-gtk3,ceibal-tatu/sugar-toolkit-gtk3,manuq/sugar-toolkit-gtk3,samdroid-apps/sugar-toolkit-gtk3,puneetgkaur/sugar-toolkit-gtk3,sugarlabs/sugar-toolkit-gtk3,samdroid-apps/sugar-toolkit-gtk3,godiard/sugar-toolkit-gtk3,sugarlabs/sugar-toolkit,i5o/sugar-toolkit-gtk3,Daksh/sugar-toolkit-gtk3,godiard/sugar-toolkit-gtk3,tchx84/debian-pkg-sugar-toolkit-gtk3,ceibal-tatu/sugar-toolkit-gtk3,ceibal-tatu/sugar-toolkit,gusDuarte/sugar-toolkit-gtk3,puneetgkaur/sugar-toolkit-gtk3,quozl/sugar-toolkit-gtk3,i5o/sugar-toolkit-gtk3,i5o/sugar-toolkit-gtk3,Daksh/sugar-toolkit-gtk3,sugarlabs/sugar-toolkit-gtk3,samdroid-apps/sugar-toolkit-gtk3,puneetgkaur/sugar-toolkit-gtk3,samdroid-apps/sugar-toolkit-gtk3,gusDuarte/sugar-toolkit-gtk3,gusDuarte/sugar-toolkit-gtk3,ceibal-tatu/sugar-toolkit-gtk3,sugarlabs/sugar-toolkit,sugarlabs/sugar-toolkit,sugarlabs/sugar-toolkit-gtk3,quozl/sugar-toolkit-gtk3,manuq/sugar-toolkit-gtk3,puneetgkaur/backup_sugar_sugartoolkit,puneetgkaur/backup_sugar_sugartoolkit,sugarlabs/sugar-toolkit,ceibal-tatu/sugar-toolkit,tchx84/sugar-toolkit-gtk3 |
161cd07fca220494e675b1da674dbf57254a28b3 | scripts/spat_gencomms.py | scripts/spat_gencomms.py | import spat_community_generation as sg
import sys
Svals = [10, 11, 13, 14, 16, 18, 21, 23, 26, 30, 34, 38, 43, 48, 55, 62, 70,
78, 89, 100]
Nvals = [120, 186, 289, 447, 694, 1076, 1668, 2587, 4011, 6220, 9646, 14957,
23193, 35965, 55769, 86479, 134099, 207941, 322444, 500000]
if len(sys.argv) > 1:
Sindex = int(sys.argv[1])
Svals = Svals[Sindex]
sg.explore_parameter_space(Svals, Nvals, 200, 12)
| import spat_community_generation as sg
import sys
Svals = [10, 11, 13, 14, 16, 18, 21, 23, 26, 30, 34, 38, 43, 48, 55, 62, 70,
78, 89, 100]
Nvals = [120, 186, 289, 447, 694, 1076, 1668, 2587, 4011, 6220, 9646, 14957,
23193, 35965, 55769, 86479, 134099, 207941, 322444, 500000]
if len(sys.argv) > 1:
Sindex = int(sys.argv[1])
Svals = [Svals[Sindex]]
sg.explore_parameter_space(Svals, Nvals, 200, 12)
| Change to ensure that the Svals were handled as a list | Change to ensure that the Svals were handled as a list
| Python | mit | weecology/mete-spatial,weecology/mete-spatial,weecology/mete-spatial,weecology/mete-spatial |
911094754fc908d99009c5cfec22ac9033ffd472 | my_account_helper/model/__init__.py | my_account_helper/model/__init__.py | # -*- encoding: utf-8 -*-
##############################################################################
#
# Copyright (C) 2015 Compassion CH (http://www.compassion.ch)
# Releasing children from poverty in Jesus' name
# @author: Emanuel Cino <[email protected]>
#
# The licence is in the file __openerp__.py
#
##############################################################################
from . import xmlrpc_helper
| # -*- encoding: utf-8 -*-
##############################################################################
#
# Copyright (C) 2015 Compassion CH (http://www.compassion.ch)
# Releasing children from poverty in Jesus' name
# @author: Emmanuel Mathier <[email protected]>
#
# The licence is in the file __openerp__.py
#
##############################################################################
from . import xmlrpc_helper
| Fix comment header on init | Fix comment header on init
| Python | agpl-3.0 | Secheron/compassion-switzerland,CompassionCH/compassion-switzerland,eicher31/compassion-switzerland,eicher31/compassion-switzerland,CompassionCH/compassion-switzerland,Secheron/compassion-switzerland,CompassionCH/compassion-switzerland,ecino/compassion-switzerland,MickSandoz/compassion-switzerland,ecino/compassion-switzerland,ecino/compassion-switzerland,ndtran/compassion-switzerland,MickSandoz/compassion-switzerland,ndtran/compassion-switzerland,eicher31/compassion-switzerland |
5c61d7f125078cb6b3bd0c5700ae9219baab0078 | webapp/tests/test_dashboard.py | webapp/tests/test_dashboard.py | from django.core.urlresolvers import reverse
from django.test import TestCase
class DashboardTest(TestCase):
def test_dashboard(self):
url = reverse('graphite.dashboard.views.dashboard')
response = self.client.get(url)
self.assertEqual(response.status_code, 200)
| from django.core.urlresolvers import reverse
from django.test import TestCase
class DashboardTest(TestCase):
def test_dashboard(self):
url = reverse('dashboard')
response = self.client.get(url)
self.assertEqual(response.status_code, 200)
| Update reverse call to use named URL | Update reverse call to use named URL
| Python | apache-2.0 | redice/graphite-web,dbn/graphite-web,Skyscanner/graphite-web,penpen/graphite-web,lyft/graphite-web,esnet/graphite-web,bpaquet/graphite-web,atnak/graphite-web,section-io/graphite-web,kkdk5535/graphite-web,cosm0s/graphite-web,cgvarela/graphite-web,gwaldo/graphite-web,redice/graphite-web,edwardmlyte/graphite-web,atnak/graphite-web,criteo-forks/graphite-web,bmhatfield/graphite-web,obfuscurity/graphite-web,AICIDNN/graphite-web,edwardmlyte/graphite-web,gwaldo/graphite-web,penpen/graphite-web,cbowman0/graphite-web,Skyscanner/graphite-web,JeanFred/graphite-web,cgvarela/graphite-web,bruce-lyft/graphite-web,criteo-forks/graphite-web,phreakocious/graphite-web,lyft/graphite-web,mcoolive/graphite-web,piotr1212/graphite-web,esnet/graphite-web,zBMNForks/graphite-web,axibase/graphite-web,blacked/graphite-web,AICIDNN/graphite-web,kkdk5535/graphite-web,atnak/graphite-web,ZelunZhang/graphite-web,graphite-server/graphite-web,cgvarela/graphite-web,graphite-server/graphite-web,zBMNForks/graphite-web,synedge/graphite-web,pu239ppy/graphite-web,axibase/graphite-web,gwaldo/graphite-web,jssjr/graphite-web,esnet/graphite-web,Skyscanner/graphite-web,bmhatfield/graphite-web,DanCech/graphite-web,lfckop/graphite-web,JeanFred/graphite-web,edwardmlyte/graphite-web,brutasse/graphite-web,esnet/graphite-web,Invoca/graphite-web,johnseekins/graphite-web,esnet/graphite-web,criteo-forks/graphite-web,mcoolive/graphite-web,pu239ppy/graphite-web,bmhatfield/graphite-web,edwardmlyte/graphite-web,ZelunZhang/graphite-web,DanCech/graphite-web,section-io/graphite-web,penpen/graphite-web,cbowman0/graphite-web,Invoca/graphite-web,markolson/graphite-web,markolson/graphite-web,Aloomaio/graphite-web,graphite-project/graphite-web,mcoolive/graphite-web,edwardmlyte/graphite-web,atnak/graphite-web,graphite-project/graphite-web,Squarespace/graphite-web,cbowman0/graphite-web,kkdk5535/graphite-web,lyft/graphite-web,criteo-forks/graphite-web,JeanFred/graphite-web,redice/graphite-web,graphite-server/graphite-web,dbn/graphite-web,pu239ppy/graphite-web,piotr1212/graphite-web,brutasse/graphite-web,phreakocious/graphite-web,mcoolive/graphite-web,lfckop/graphite-web,penpen/graphite-web,DanCech/graphite-web,johnseekins/graphite-web,blacked/graphite-web,bpaquet/graphite-web,cbowman0/graphite-web,cgvarela/graphite-web,markolson/graphite-web,bpaquet/graphite-web,graphite-project/graphite-web,bpaquet/graphite-web,bruce-lyft/graphite-web,Invoca/graphite-web,Squarespace/graphite-web,lyft/graphite-web,synedge/graphite-web,bbc/graphite-web,piotr1212/graphite-web,pu239ppy/graphite-web,johnseekins/graphite-web,JeanFred/graphite-web,DanCech/graphite-web,obfuscurity/graphite-web,lyft/graphite-web,cosm0s/graphite-web,Invoca/graphite-web,deniszh/graphite-web,krux/graphite-web,bbc/graphite-web,goir/graphite-web,Squarespace/graphite-web,DanCech/graphite-web,Aloomaio/graphite-web,bpaquet/graphite-web,johnseekins/graphite-web,disqus/graphite-web,penpen/graphite-web,section-io/graphite-web,cgvarela/graphite-web,lfckop/graphite-web,Invoca/graphite-web,jssjr/graphite-web,AICIDNN/graphite-web,bruce-lyft/graphite-web,cosm0s/graphite-web,ZelunZhang/graphite-web,graphite-project/graphite-web,zBMNForks/graphite-web,cgvarela/graphite-web,JeanFred/graphite-web,piotr1212/graphite-web,goir/graphite-web,cbowman0/graphite-web,drax68/graphite-web,criteo-forks/graphite-web,synedge/graphite-web,synedge/graphite-web,nkhuyu/graphite-web,JeanFred/graphite-web,phreakocious/graphite-web,Aloomaio/graphite-web,bbc/graphite-web,phreakocious/graphite-web,cosm0s/graphite-web,phreakocious/graphite-web,brutasse/graphite-web,graphite-server/graphite-web,Squarespace/graphite-web,gwaldo/graphite-web,cosm0s/graphite-web,deniszh/graphite-web,pu239ppy/graphite-web,blacked/graphite-web,Invoca/graphite-web,krux/graphite-web,AICIDNN/graphite-web,redice/graphite-web,piotr1212/graphite-web,cbowman0/graphite-web,section-io/graphite-web,obfuscurity/graphite-web,redice/graphite-web,section-io/graphite-web,deniszh/graphite-web,krux/graphite-web,nkhuyu/graphite-web,gwaldo/graphite-web,nkhuyu/graphite-web,graphite-server/graphite-web,deniszh/graphite-web,goir/graphite-web,Aloomaio/graphite-web,drax68/graphite-web,markolson/graphite-web,krux/graphite-web,obfuscurity/graphite-web,dbn/graphite-web,bruce-lyft/graphite-web,markolson/graphite-web,bmhatfield/graphite-web,brutasse/graphite-web,atnak/graphite-web,Skyscanner/graphite-web,krux/graphite-web,blacked/graphite-web,kkdk5535/graphite-web,jssjr/graphite-web,goir/graphite-web,lfckop/graphite-web,bmhatfield/graphite-web,cosm0s/graphite-web,Squarespace/graphite-web,disqus/graphite-web,ZelunZhang/graphite-web,Aloomaio/graphite-web,axibase/graphite-web,disqus/graphite-web,bbc/graphite-web,ZelunZhang/graphite-web,redice/graphite-web,goir/graphite-web,bruce-lyft/graphite-web,ZelunZhang/graphite-web,AICIDNN/graphite-web,axibase/graphite-web,mcoolive/graphite-web,disqus/graphite-web,johnseekins/graphite-web,drax68/graphite-web,drax68/graphite-web,lyft/graphite-web,graphite-project/graphite-web,lfckop/graphite-web,bmhatfield/graphite-web,blacked/graphite-web,axibase/graphite-web,axibase/graphite-web,krux/graphite-web,disqus/graphite-web,drax68/graphite-web,bbc/graphite-web,criteo-forks/graphite-web,pu239ppy/graphite-web,obfuscurity/graphite-web,nkhuyu/graphite-web,drax68/graphite-web,jssjr/graphite-web,obfuscurity/graphite-web,kkdk5535/graphite-web,jssjr/graphite-web,bruce-lyft/graphite-web,Aloomaio/graphite-web,kkdk5535/graphite-web,zBMNForks/graphite-web,DanCech/graphite-web,dbn/graphite-web,Squarespace/graphite-web,AICIDNN/graphite-web,zBMNForks/graphite-web,section-io/graphite-web,mcoolive/graphite-web,edwardmlyte/graphite-web,synedge/graphite-web,graphite-project/graphite-web,atnak/graphite-web,nkhuyu/graphite-web,brutasse/graphite-web,jssjr/graphite-web,disqus/graphite-web,johnseekins/graphite-web,synedge/graphite-web,Skyscanner/graphite-web,Skyscanner/graphite-web,lfckop/graphite-web,zBMNForks/graphite-web,deniszh/graphite-web,nkhuyu/graphite-web,penpen/graphite-web,dbn/graphite-web,blacked/graphite-web,brutasse/graphite-web,deniszh/graphite-web,graphite-server/graphite-web,bpaquet/graphite-web,gwaldo/graphite-web,goir/graphite-web,phreakocious/graphite-web,piotr1212/graphite-web,dbn/graphite-web |
4124297475fb7d77bf492e721a74fcfa02547a14 | benchmark/bench_logger_level_low.py | benchmark/bench_logger_level_low.py | """Benchmarks too low logger levels"""
from logbook import Logger, ERROR
log = Logger('Test logger')
log.level = ERROR
def run():
for x in xrange(500):
log.warning('this is not handled')
| """Benchmarks too low logger levels"""
from logbook import Logger, StreamHandler, ERROR
from cStringIO import StringIO
log = Logger('Test logger')
log.level = ERROR
def run():
out = StringIO()
with StreamHandler(out):
for x in xrange(500):
log.warning('this is not handled')
| Create a stream handler even though it's not used to have the same overhead on both logbook and logging | Create a stream handler even though it's not used to have the same overhead on both logbook and logging
| Python | bsd-3-clause | DasIch/logbook,maykinmedia/logbook,alonho/logbook,fayazkhan/logbook,maykinmedia/logbook,Rafiot/logbook,dvarrazzo/logbook,mbr/logbook,mitsuhiko/logbook,dvarrazzo/logbook,RazerM/logbook,FintanH/logbook,omergertel/logbook,dommert/logbook,DasIch/logbook,alex/logbook,alonho/logbook,pombredanne/logbook,alonho/logbook,alex/logbook,DasIch/logbook,mbr/logbook,fayazkhan/logbook,narfdotpl/logbook,redtoad/logbook,redtoad/logbook,Rafiot/logbook,omergertel/logbook,Rafiot/logbook,omergertel/logbook |
912b2e1f1ce3dbca94e8cdf869c9906c43d5cc8d | opentreemap/ecobenefits/__init__.py | opentreemap/ecobenefits/__init__.py | from species import CODES
def all_region_codes():
return CODES.keys
def all_species_codes():
return species_codes_for_regions(all_region_codes)
def species_codes_for_regions(region_codes):
if region_codes is None:
return None
species_codes = []
for region_code in region_codes:
species_codes.extend(CODES[region_code])
# Converting to a set removes duplicates
return list(set(species_codes))
| from species import CODES
def all_region_codes():
return CODES.keys
def all_species_codes():
return species_codes_for_regions(all_region_codes())
def species_codes_for_regions(region_codes):
if region_codes is None:
return None
species_codes = []
for region_code in region_codes:
species_codes.extend(CODES[region_code])
# Converting to a set removes duplicates
return list(set(species_codes))
| Fix typo that prevented instance creation | Fix typo that prevented instance creation
| Python | agpl-3.0 | recklessromeo/otm-core,RickMohr/otm-core,clever-crow-consulting/otm-core,RickMohr/otm-core,RickMohr/otm-core,maurizi/otm-core,recklessromeo/otm-core,maurizi/otm-core,RickMohr/otm-core,maurizi/otm-core,clever-crow-consulting/otm-core,recklessromeo/otm-core,recklessromeo/otm-core,clever-crow-consulting/otm-core,maurizi/otm-core,clever-crow-consulting/otm-core |
b71db5eb72fd5529be060d5f90ad744f0ea0870e | library.py | library.py | class Library:
"""This class represents a simaris target and is initialized with
data in JSON format
"""
def __init__(self, data):
self.target = data['CurrentTarget']['EnemyType']
self.scans = data['CurrentTarget']['PersonalScansRequired']
self.progress = data['CurrentTarget']['ProgressPercent']
def __str__(self):
"""Returns a string with all the information about this alert
"""
library_string = ('Target: {0}\n'
'Scans needed: {1}\n'
'Progress: {2:.2f}%'
)
return library_string.format(self.target, self.scans,
self.progress) | class Library:
"""This class represents a simaris target and is initialized with
data in JSON format
"""
def __init__(self, data):
if 'CurrentTarget' in data:
self.target = data['CurrentTarget']['EnemyType']
self.scans = data['CurrentTarget']['PersonalScansRequired']
self.progress = data['CurrentTarget']['ProgressPercent']
self.active = True
else:
self.active = False
def __str__(self):
"""Returns a string with all the information about this alert
"""
if not self.is_active():
return None
library_string = ('Target: {0}\n'
'Scans needed: {1}\n'
'Progress: {2:.2f}%'
)
return library_string.format(self.target, self.scans,
self.progress)
def is_active(self):
""" Returns True if there is a currently active target, False otherwise
"""
return self.active
| Add is_active() method to the Library class | Add is_active() method to the Library class
| Python | mit | pabletos/Hubot-Warframe,pabletos/Hubot-Warframe |
5c6f277caf3496da5f10b0150abb2c3b856e6584 | nagare/services/prg.py | nagare/services/prg.py | # --
# Copyright (c) 2008-2020 Net-ng.
# All rights reserved.
#
# This software is licensed under the BSD License, as described in
# the file LICENSE.txt, which you should have received as part of
# this distribution.
# --
"""If the ``activated`` parameter of the ``[redirect_after_post]``
section is `on`` (the default), conform to the PRG__ pattern
__ http://en.wikipedia.org/wiki/Post/Redirect/GetPRG
"""
from nagare.services import plugin
class PRGService(plugin.Plugin):
LOAD_PRIORITY = 120
@staticmethod
def handle_request(chain, request, response, session_id, previous_state_id, **params):
if (request.method == 'POST') and not request.is_xhr:
response = request.create_redirect_response(
response=response,
_s=session_id,
_c='%05d' % previous_state_id
)
response.use_same_state = True
else:
response = chain.next(
request=request,
response=response,
session_id=session_id,
previous_state_id=previous_state_id,
**params
)
return response
| # --
# Copyright (c) 2008-2020 Net-ng.
# All rights reserved.
#
# This software is licensed under the BSD License, as described in
# the file LICENSE.txt, which you should have received as part of
# this distribution.
# --
"""If the ``activated`` parameter of the ``[redirect_after_post]``
section is `on`` (the default), conform to the PRG__ pattern
__ http://en.wikipedia.org/wiki/Post/Redirect/GetPRG
"""
from nagare.services import plugin
class PRGService(plugin.Plugin):
LOAD_PRIORITY = 120
@staticmethod
def handle_request(chain, request, response, session_id, state_id, **params):
if (request.method == 'POST') and not request.is_xhr:
response = request.create_redirect_response(
response=response,
_s=session_id,
_c='%05d' % state_id,
)
else:
response = chain.next(
request=request,
response=response,
session_id=session_id,
state_id=state_id,
**params
)
return response
| Store in the current state, not the previous one | Store in the current state, not the previous one
| Python | bsd-3-clause | nagareproject/core,nagareproject/core |
175a8fa2aa595132cf6dbf8ed405bb0682ab95dd | mkdocs/gh_deploy.py | mkdocs/gh_deploy.py | import subprocess
import os
def gh_deploy(config):
if not os.path.exists('.git'):
print 'Cannot deploy - this directory does not appear to be a git repository'
return
print "Copying '%s' to `gh-pages` branch and pushing to GitHub." % config['site_dir']
try:
subprocess.check_call(['ghp-import', '-p', config['site_dir']])
except:
return
# TODO: Also check for CNAME file
url = subprocess.check_output(["git", "config", "--get", "remote.origin.url"])
url = url.decode('utf-8').strip()
if 'github.com/' in url:
host, path = url.split('github.com/', 1)
else:
host, path = url.split('github.com:', 1)
username, repo = path.split('/', 1)
if repo.endswith('.git'):
repo = repo[:-len('.git')]
url = 'http://%s.github.io/%s' % (username, repo)
print 'Your documentation should shortly be available at: ' + url
| import subprocess
import os
def gh_deploy(config):
if not os.path.exists('.git'):
print 'Cannot deploy - this directory does not appear to be a git repository'
return
print "Copying '%s' to `gh-pages` branch and pushing to GitHub." % config['site_dir']
try:
subprocess.check_call(['ghp-import', '-p', config['site_dir']])
except:
return
# TODO: Also check for CNAME file
url = subprocess.check_output(["git", "config", "--get", "remote.origin.url"])
url = url.decode('utf-8').strip()
if 'github.com/' in url:
host, path = url.split('github.com/', 1)
else:
host, path = url.split('github.com:', 1)
username, repo = path.split('/', 1)
if repo.endswith('.git'):
repo = repo[:-len('.git')]
url = 'http://%s.github.io/%s' % (username, repo)
print 'Your documentation should shortly be available at: ' + url
| Fix build error caused by wrong indentation | Fix build error caused by wrong indentation
| Python | bsd-2-clause | fujita-shintaro/mkdocs,peter1000/mkdocs,waylan/mkdocs,fujita-shintaro/mkdocs,mlzummo/mkdocs,michaelmcandrew/mkdocs,jimporter/mkdocs,kubikusrubikus/mkdocs,samhatfield/mkdocs,d0ugal/mkdocs,williamjmorenor/mkdocs,ericholscher/mkdocs,jeoygin/mkdocs,michaelmcandrew/mkdocs,nicoddemus/mkdocs,tedmiston/mkdocs,cazzerson/mkdocs,peter1000/mkdocs,jamesbeebop/mkdocs,tedmiston/mkdocs,samuelcolvin/mkdocs,rickpeters/mkdocs,jpush/mkdocs,xeechou/mkblogs,cazzerson/mkdocs,waylan/mkdocs,cnbin/mkdocs,kubikusrubikus/mkdocs,jimporter/mkdocs,xeechou/mkblogs,pjbull/mkdocs,pjbull/mkdocs,cnbin/mkdocs,dmehra/mkdocs,waylan/mkdocs,mkdocs/mkdocs,samuelcolvin/mkdocs,davidgillies/mkdocs,wenqiuhua/mkdocs,mlzummo/mkdocs,samhatfield/mkdocs,lukfor/mkdocs,longjl/mkdocs,fujita-shintaro/mkdocs,longjl/mkdocs,jeoygin/mkdocs,longjl/mkdocs,mkdocs/mkdocs,lukfor/mkdocs,lukfor/mkdocs,xeechou/mkblogs,ericholscher/mkdocs,mkdocs/mkdocs,ramramps/mkdocs,ramramps/mkdocs,wenqiuhua/mkdocs,lbenet/mkdocs,samuelcolvin/mkdocs,lbenet/mkdocs,tedmiston/mkdocs,cnbin/mkdocs,gregelin/mkdocs,cazzerson/mkdocs,lbenet/mkdocs,kubikusrubikus/mkdocs,michaelmcandrew/mkdocs,vi4m/mkdocs,mlzummo/mkdocs,peter1000/mkdocs,jamesbeebop/mkdocs,samhatfield/mkdocs,hhg2288/mkdocs,d0ugal/mkdocs,xeechou/mkblogs,hhg2288/mkdocs,gregelin/mkdocs,gregelin/mkdocs,simonfork/mkdocs,nicoddemus/mkdocs,williamjmorenor/mkdocs,vi4m/mkdocs,pjbull/mkdocs,davidgillies/mkdocs,jpush/mkdocs,davidgillies/mkdocs,wenqiuhua/mkdocs,dmehra/mkdocs,jimporter/mkdocs,jeoygin/mkdocs,rickpeters/mkdocs,nicoddemus/mkdocs,justinkinney/mkdocs,williamjmorenor/mkdocs,cazzerson/mkdocs,simonfork/mkdocs,justinkinney/mkdocs,justinkinney/mkdocs,ramramps/mkdocs,wenqiuhua/mkdocs,hhg2288/mkdocs,jamesbeebop/mkdocs,d0ugal/mkdocs,rickpeters/mkdocs,dmehra/mkdocs,simonfork/mkdocs,vi4m/mkdocs,jpush/mkdocs,jpush/mkdocs,ericholscher/mkdocs |
c1d8bf0916e1f59610fc69f0b11909964755ee38 | pyaavso/formats/visual.py | pyaavso/formats/visual.py | from __future__ import unicode_literals
class VisualFormatWriter(object):
"""
A class responsible for writing observation data in AAVSO
`Visual File Format`_.
The API here mimics the ``csv`` module in Python standard library.
.. _`Visual File Format`: http://www.aavso.org/aavso-visual-file-format
"""
def __init__(self, fp, observer_code, delimiter=',', date_format='JD', obstype='Visual'):
"""
Creates the writer which will write observations into the file-like
object given in first parameter. The only other required parameter
is the official AAVSO-assigned observer code.
"""
self.observer_code = observer_code
self.date_format = date_format
self.obstype = obstype
fp.write('#TYPE=Visual\n')
fp.write('#OBSCODE=%s\n' % observer_code)
| from __future__ import unicode_literals
import pyaavso
class VisualFormatWriter(object):
"""
A class responsible for writing observation data in AAVSO
`Visual File Format`_.
The API here mimics the ``csv`` module in Python standard library.
.. _`Visual File Format`: http://www.aavso.org/aavso-visual-file-format
"""
def __init__(self, fp, observer_code, delimiter=',', date_format='JD', obstype='Visual'):
"""
Creates the writer which will write observations into the file-like
object given in first parameter. The only other required parameter
is the official AAVSO-assigned observer code.
"""
self.observer_code = observer_code
self.date_format = date_format
self.obstype = obstype
fp.write('#TYPE=Visual\n')
fp.write('#OBSCODE=%s\n' % observer_code)
fp.write("#SOFTWARE=pyaavso %s\n" % pyaavso.get_version())
| Write name and version to output file. | Write name and version to output file.
| Python | mit | zsiciarz/pyaavso |
533ed337dd5f6087ac059ed47f1a0ce344ce48ce | src/utils/playbook.py | src/utils/playbook.py | from django.conf import settings
from ansible.models import Playbook
import os
def content_loader(pk, slug):
playbook = Playbook.query_set.get(pk=pk)
playbook_dir = playbook.directory
# TODO: for now assume without validation
playbook_file = os.path.join(playbook_dir, slug + '.yml')
with open(playbook_file, 'r') as f:
content = f.read()
return content
| from django.conf import settings
from ansible.models import Playbook
import os
def content_loader(pk, slug):
playbook = Playbook.query_set.get(pk=pk)
playbook_dir = playbook.directory
# TODO: for now assume without validation
playbook_file = os.path.join(playbook_dir, slug + '.yml')
with open(playbook_file, 'r') as f:
content = f.read()
return content
def write_content(pk, slug, data):
playbook = Playbook.query_set.get(pk=pk)
#TODO: assume for now file ends with '.yml'
playbook_file = slug + '.yml'
playbook_file = os.path.join(playbook.get_dir_name(), playbook_file)
f = open(playbook_file, "w")
f.write(data)
f.close
| Add util func to write content | Add util func to write content
| Python | bsd-3-clause | lozadaOmr/ansible-admin,lozadaOmr/ansible-admin,lozadaOmr/ansible-admin |
313aee17c8e2e1c86b96b40017ac4618c66df463 | __init__.py | __init__.py | # -*- coding: utf-8 -*-
# This file is part of OpenFisca
# Copyright © 2012 Mahdi Ben Jelloul, Clément Schaff
# Licensed under the terms of the GPL License v3 or later version
# (see src/__init__.py for details)
# Model parameters
ENTITIES_INDEX = ['men', 'foy']
# Some variables needed by the test case plugins
CURRENCY = u"DT"
# Some variables needed by the test case graph widget
# REVENUES_CATEGORIES
XAXIS_PROPERTIES = { 'sali': {
'name' : 'sal',
'typ_tot' : {'salsuperbrut' : 'Salaire super brut',
'salbrut': 'Salaire brut',
'sal': 'Salaire imposable',
'salnet': 'Salaire net'},
'typ_tot_default' : 'sal'},
}
# Some variables used by other plugins
| # -*- coding: utf-8 -*-
# This file is part of OpenFisca
# Copyright © 2012 Mahdi Ben Jelloul, Clément Schaff
# Licensed under the terms of the GPL License v3 or later version
# (see src/__init__.py for details)
# Model parameters
ENTITIES_INDEX = ['men', 'foy']
# Some variables needed by the test case plugins
CURRENCY = u"DT"
# Some variables needed by the test case graph widget
REVENUES_CATEGORIES = {'imposable' : ['sal',]}
XAXIS_PROPERTIES = { 'sali': {
'name' : 'sal',
'typ_tot' : {'salsuperbrut' : 'Salaire super brut',
'salbrut': 'Salaire brut',
'sal': 'Salaire imposable',
'salnet': 'Salaire net'},
'typ_tot_default' : 'sal'},
}
# Some variables used by other plugins
| Generalize graph and some new example scripts | Generalize graph and some new example scripts
| Python | agpl-3.0 | openfisca/openfisca-tunisia,openfisca/openfisca-tunisia |
2b1b4ab1bfa494021197756d3877f38e1b290435 | server_common/helpers.py | server_common/helpers.py | import json
import os
import sys
from server_common.ioc_data_source import IocDataSource
from server_common.mysql_abstraction_layer import SQLAbstraction
from server_common.utilities import print_and_log, SEVERITY
def register_ioc_start(ioc_name, pv_database=None, prefix=None):
"""
A helper function to register the start of an ioc.
Args:
ioc_name: name of the ioc to start
pv_database: doctionary of pvs in the iov
prefix: prefix of pvs in this ioc
"""
try:
exepath = sys.argv[0]
if pv_database is None:
pv_database = {}
if prefix is None:
prefix = "none"
ioc_data_source = IocDataSource(SQLAbstraction("iocdb", "iocdb", "$iocdb"))
ioc_data_source.insert_ioc_start(ioc_name, os.getpid(), exepath, pv_database, prefix)
except Exception as e:
print_and_log("Error registering ioc start: {}: {}".format(e.__class__.__name__, e), SEVERITY.MAJOR)
def get_macro_values():
"""
Parse macro environment JSON into dict. To make this work use the icpconfigGetMacros program.
Returns: Macro Key:Value pairs as dict
"""
macros = json.loads(os.environ.get("REFL_MACROS", ""))
macros = {key: value for (key, value) in macros.items()}
return macros
| import json
import os
import sys
from server_common.ioc_data_source import IocDataSource
from server_common.mysql_abstraction_layer import SQLAbstraction
from server_common.utilities import print_and_log, SEVERITY
def register_ioc_start(ioc_name, pv_database=None, prefix=None):
"""
A helper function to register the start of an ioc.
Args:
ioc_name: name of the ioc to start
pv_database: doctionary of pvs in the iov
prefix: prefix of pvs in this ioc
"""
try:
exepath = sys.argv[0]
if pv_database is None:
pv_database = {}
if prefix is None:
prefix = "none"
ioc_data_source = IocDataSource(SQLAbstraction("iocdb", "iocdb", "$iocdb"))
ioc_data_source.insert_ioc_start(ioc_name, os.getpid(), exepath, pv_database, prefix)
except Exception as e:
print_and_log("Error registering ioc start: {}: {}".format(e.__class__.__name__, e), SEVERITY.MAJOR)
def get_macro_values():
"""
Parse macro environment JSON into dict. To make this work use the icpconfigGetMacros program.
Returns: Macro Key:Value pairs as dict
"""
macros = json.loads(os.environ.get("REFL_MACROS", "{}"))
macros = {key: value for (key, value) in macros.items()}
return macros
| Return empty dict if not defined rather than error | Return empty dict if not defined rather than error
| Python | bsd-3-clause | ISISComputingGroup/EPICS-inst_servers,ISISComputingGroup/EPICS-inst_servers |
fb4d11f1c96d48dd71bc12921763681149da4616 | eultheme/context_processors.py | eultheme/context_processors.py | import datetime
from django.conf import settings
from django.contrib.sites.models import get_current_site
from django.utils.functional import SimpleLazyObject
from django.utils.timezone import utc
from downtime.models import Period
from .models import Banner
def template_settings(request):
'''Template context processor: add selected setting to context
so it can be used on any page .'''
context_extras = {
'ENABLE_BETA_WARNING': getattr(settings, 'ENABLE_BETA_WARNING', False),
'EULTHEME_NO_EXTERNAL_JS': getattr(settings, 'EULTHEME_NO_EXTERNAL_JS', False)}
return context_extras
def site_path(request):
'''Template context processor: provides access to current
:class:`~django.contrib.sites.models.Site` and
the site root path for use in building absolute urls.
'''
site = SimpleLazyObject(lambda: get_current_site(request))
protocol = 'https' if request.is_secure() else 'http'
return {
'site': site,
'site_root': SimpleLazyObject(lambda: "%s://%s" % (protocol, site.domain))}
def downtime_context(request):
'''Template context processor: add relevant maintenance banner to site.'''
banner = Banner.objects.get_deployed().first()
context = {}
if banner:
context.update({'banner': banner})
site_is_down = Period.objects.is_down()
if site_is_down:
context.update({'site_is_down': site_is_down})
return context
| import datetime
from django.conf import settings
from django.contrib.sites.shortcuts import get_current_site
from django.utils.functional import SimpleLazyObject
from django.utils.timezone import utc
from downtime.models import Period
from .models import Banner
def template_settings(request):
'''Template context processor: add selected setting to context
so it can be used on any page .'''
context_extras = {
'ENABLE_BETA_WARNING': getattr(settings, 'ENABLE_BETA_WARNING', False),
'EULTHEME_NO_EXTERNAL_JS': getattr(settings, 'EULTHEME_NO_EXTERNAL_JS', False)}
return context_extras
def site_path(request):
'''Template context processor: provides access to current
:class:`~django.contrib.sites.models.Site` and
the site root path for use in building absolute urls.
'''
site = SimpleLazyObject(lambda: get_current_site(request))
protocol = 'https' if request.is_secure() else 'http'
return {
'site': site,
'site_root': SimpleLazyObject(lambda: "%s://%s" % (protocol, site.domain))}
def downtime_context(request):
'''Template context processor: add relevant maintenance banner to site.'''
banner = Banner.objects.get_deployed().first()
context = {}
if banner:
context.update({'banner': banner})
site_is_down = Period.objects.is_down()
if site_is_down:
context.update({'site_is_down': site_is_down})
return context
| Update to import for for Django 1.9 compatibility. | Update to import for for Django 1.9 compatibility.
| Python | apache-2.0 | emory-libraries/django-eultheme,emory-libraries/django-eultheme,emory-libraries/django-eultheme |
09fc3d53b2814f940bcaf7d6136ed2ce0595fb2f | hyperion/importers/tests/test_sph.py | hyperion/importers/tests/test_sph.py | import os
import h5py
import numpy as np
from ..sph import construct_octree
DATA = os.path.join(os.path.dirname(__file__), 'data')
def test_construct_octree():
np.random.seed(0)
N = 5000
px = np.random.uniform(-10., 10., N)
py = np.random.uniform(-10., 10., N)
pz = np.random.uniform(-10., 10., N)
mass = np.random.uniform(0., 1., N)
sigma = np.random.uniform(0., 0.1, N)
o = construct_octree(0.1, 0.2, 0.3, 6., 5., 4.,
px, py, pz,
sigma, mass, n_levels=10)
# The following lines can be used to write out the reference file if the
# SPH gridding code is updated.
# f = h5py.File('reference_octree.hdf5', 'w')
# o.write(f)
# f.close()
from hyperion.grid import OctreeGrid
f = h5py.File(os.path.join(DATA, 'reference_octree.hdf5'), 'r')
o_ref = OctreeGrid()
o_ref.read(f)
f.close()
assert np.all(o_ref.refined == o.refined)
assert np.all(o_ref['density'][0].array == o['density'][0].array)
| import os
import h5py
import numpy as np
from numpy.testing import assert_allclose
from ..sph import construct_octree
DATA = os.path.join(os.path.dirname(__file__), 'data')
def test_construct_octree():
np.random.seed(0)
N = 5000
px = np.random.uniform(-10., 10., N)
py = np.random.uniform(-10., 10., N)
pz = np.random.uniform(-10., 10., N)
mass = np.random.uniform(0., 1., N)
sigma = np.random.uniform(0., 0.1, N)
o = construct_octree(0.1, 0.2, 0.3, 6., 5., 4.,
px, py, pz,
sigma, mass, n_levels=10)
# The following lines can be used to write out the reference file if the
# SPH gridding code is updated.
# f = h5py.File('reference_octree.hdf5', 'w')
# o.write(f)
# f.close()
from hyperion.grid import OctreeGrid
f = h5py.File(os.path.join(DATA, 'reference_octree.hdf5'), 'r')
o_ref = OctreeGrid()
o_ref.read(f)
f.close()
assert np.all(o_ref.refined == o.refined)
assert_allclose(o_ref['density'][0].array, o['density'][0].array)
| Use assert_allclose for comparison of octree densities | Use assert_allclose for comparison of octree densities
| Python | bsd-2-clause | hyperion-rt/hyperion,bluescarni/hyperion,hyperion-rt/hyperion,hyperion-rt/hyperion,bluescarni/hyperion |
30f32266a1f8ac698d9da5da79c88867e781084a | packages/reward-root-submitter/reward_root_submitter/config.py | packages/reward-root-submitter/reward_root_submitter/config.py | from functools import lru_cache
import boto3
from pydantic import BaseSettings, Field, root_validator
@lru_cache
def get_secrets_client():
return boto3.client("secretsmanager")
@lru_cache
def get_secret(secret_id):
client = get_secrets_client()
secret_value = client.get_secret_value(SecretId=secret_id)
return secret_value["SecretString"]
class Config(BaseSettings):
environment: str
evm_full_node_url: str
reward_root_submitter_address: str
reward_root_submitter_private_key: str
reward_root_submitter_sentry_dsn: str
log_level: str = Field("WARNING")
@root_validator(pre=True)
def load_secrets(cls, values):
env = values["environment"]
for field_name, field in cls.__fields__.items():
# Check it isn't already set *and* there is no default
if field_name not in values and field.default is None:
values[field_name] = get_secret(f"{env}_{field_name}")
return values
class Config:
env_file = ".env"
env_file_encoding = "utf-8"
| from functools import lru_cache
import boto3
from pydantic import BaseSettings, Field, root_validator
@lru_cache
def get_secrets_client():
return boto3.client("secretsmanager")
@lru_cache
def get_secret(secret_id):
client = get_secrets_client()
secret_value = client.get_secret_value(SecretId=secret_id)
return secret_value["SecretString"]
class Config(BaseSettings):
environment: str
evm_full_node_url: str
reward_root_submitter_address: str
reward_root_submitter_private_key: str
reward_root_submitter_sentry_dsn: str
log_level: str = Field("INFO")
@root_validator(pre=True)
def load_secrets(cls, values):
env = values["environment"]
for field_name, field in cls.__fields__.items():
# Check it isn't already set *and* there is no default
if field_name not in values and field.default is None:
values[field_name] = get_secret(f"{env}_{field_name}")
return values
class Config:
env_file = ".env"
env_file_encoding = "utf-8"
| Set default logging to info | Set default logging to info
| Python | mit | cardstack/cardstack,cardstack/cardstack,cardstack/cardstack,cardstack/cardstack,cardstack/cardstack,cardstack/cardstack |
fd96170fd15ccbe0b42463fe8d4ac78f511d10c7 | example/testtags/admin.py | example/testtags/admin.py | from django.contrib import admin
from models import TestName
class TestNameAdmin(admin.ModelAdmin):
model = TestName
alphabet_filter = 'sorted_name'
admin.site.register(TestName, TestNameAdmin) | from django.contrib import admin
from models import TestName
class TestNameAdmin(admin.ModelAdmin):
model = TestName
alphabet_filter = 'sorted_name'
## Testing a custom Default Alphabet
#DEFAULT_ALPHABET = 'ABC'
## Testing a blank alphabet-- only shows the characters in the database
#DEFAULT_ALPHABET = ''
## Testing a callable
def DEFAULT_ALPHABET(self):
return "I D K W"
admin.site.register(TestName, TestNameAdmin) | Put in some testing code to test the new overrides | Put in some testing code to test the new overrides
| Python | apache-2.0 | bltravis/django-alphabetfilter,affan2/django-alphabetfilter,affan2/django-alphabetfilter,affan2/django-alphabetfilter,bltravis/django-alphabetfilter,bltravis/django-alphabetfilter |
8165aa65e96d32ed908cdf8e3c475c28181e0d93 | hierarchical_auth/admin.py | hierarchical_auth/admin.py | from django.contrib import admin
from django.conf import settings
from django.contrib.auth.models import Group, User
from django.contrib.auth.admin import GroupAdmin, UserAdmin
from django.contrib.auth.forms import UserChangeForm
from mptt.forms import TreeNodeMultipleChoiceField
if getattr(settings, 'MPTT_USE_FEINCMS', False):
from mptt.admin import FeinCMSModelAdmin
class GroupMPTTModelAdmin(GroupAdmin, FeinCMSModelAdmin):
pass
else:
from mptt.admin import MPTTModelAdmin
class GroupMPTTModelAdmin(GroupAdmin, MPTTModelAdmin):
pass
admin.site.unregister(Group)
admin.site.register(Group, GroupMPTTModelAdmin)
class UserWithMPTTChangeForm(UserChangeForm):
groups = TreeNodeMultipleChoiceField(queryset=Group.tree.all())
class UserWithMPTTAdmin(UserAdmin):
form = UserWithMPTTChangeForm
admin.site.unregister(User)
admin.site.register(User, UserWithMPTTAdmin)
| from django.contrib import admin
from django.conf import settings
from django.contrib.auth.models import Group
from django.contrib.auth.admin import GroupAdmin
from django.contrib.auth.forms import UserChangeForm
try:
User = settings.AUTH_USER_MODEL
except:
from django.contrib.auth.models import User
try:
UserAdmin = settings.AUTH_USER_ADMIN_MODEL
except:
from django.contrib.auth.admin import UserAdmin
from mptt.forms import TreeNodeMultipleChoiceField
if getattr(settings, 'MPTT_USE_FEINCMS', False):
from mptt.admin import FeinCMSModelAdmin
class GroupMPTTModelAdmin(GroupAdmin, FeinCMSModelAdmin):
pass
else:
from mptt.admin import MPTTModelAdmin
class GroupMPTTModelAdmin(GroupAdmin, MPTTModelAdmin):
pass
admin.site.unregister(Group)
admin.site.register(Group, GroupMPTTModelAdmin)
class UserWithMPTTChangeForm(UserChangeForm):
groups = TreeNodeMultipleChoiceField(queryset=Group.tree.all())
class UserWithMPTTAdmin(UserAdmin):
form = UserWithMPTTChangeForm
admin.site.unregister(User)
admin.site.register(User, UserWithMPTTAdmin)
| Work with custom user models in django >= 1.5 | Work with custom user models in django >= 1.5
Work with Custom User Models introduced in django >= 1.5
Also tries to get a AUTH_USER_ADMIN_MODEL, not only AUTH_USER_MODEL | Python | bsd-3-clause | zhangguiyu/django-hierarchical-auth,digitalemagine/django-hierarchical-auth |
731e48b1b81e9249fc8bdd0f826c6e009559fcc3 | mempoke.py | mempoke.py | import gdb
import struct
class DeviceMemory:
def __init__(self):
self.inferior = gdb.selected_inferior()
def __del__(self):
del self.inferior
def read(self, address):
return struct.unpack('I', self.inferior.read_memory(address, 4))[0]
def write(self, address, value):
value_bytes = struct.pack('I', value)
self.inferior.write_memory(address, value_bytes)
| import gdb
import struct
class DeviceMemory:
def __init__(self):
self.inferior = gdb.selected_inferior()
def __del__(self):
del self.inferior
def read(self, address):
return struct.unpack('I', self.inferior.read_memory(address, 4))[0]
def write(self, address, value):
value_bytes = struct.pack('I', value)
self.inferior.write_memory(address, value_bytes)
def create_memory_reg(offset, name):
def reg_getter(self):
return self.device_memory.read(self.address + offset)
def reg_setter(self, value):
self.device_memory.write(self.address + offset, value)
return property(reg_getter, reg_setter, None, name)
def create_mem_struct(name, registers):
structure_fields = {}
for register, offset in registers:
structure_fields[register] = create_memory_reg(offset, register)
def memory_structure_init(self, address, device_memory):
self.address = address
self.device_memory = device_memory
structure_fields['__init__'] = memory_structure_init
return type(name, (object,), structure_fields)
| Add mechanism for defining MCU control structures | Add mechanism for defining MCU control structures
| Python | mit | fmfi-svt-deadlock/hw-testing,fmfi-svt-deadlock/hw-testing |
65cd0c8865761af434756b313c7e29b1904e647c | h2o-py/tests/testdir_algos/rf/pyunit_bigcatRF.py | h2o-py/tests/testdir_algos/rf/pyunit_bigcatRF.py | import sys
sys.path.insert(1, "../../../")
import h2o
def bigcatRF(ip,port):
# Connect to h2o
h2o.init(ip,port)
# Training set has 100 categories from cat001 to cat100
# Categories cat001, cat003, ... are perfect predictors of y = 1
# Categories cat002, cat004, ... are perfect predictors of y = 0
#Log.info("Importing bigcat_5000x2.csv data...\n")
bigcat = h2o.import_frame(path=h2o.locate("smalldata/gbm_test/bigcat_5000x2.csv"))
bigcat["y"] = bigcat["y"].asfactor()
#Log.info("Summary of bigcat_5000x2.csv from H2O:\n")
#bigcat.summary()
# Train H2O DRF Model:
#Log.info("H2O DRF (Naive Split) with parameters:\nclassification = TRUE, ntree = 1, depth = 1, nbins = 100\n")
model = h2o.random_forest(x=bigcat[["X"]], y=bigcat["y"], ntrees=1, max_depth=1, nbins=100)
model.show()
if __name__ == "__main__":
h2o.run_test(sys.argv, bigcatRF)
| import sys
sys.path.insert(1, "../../../")
import h2o
def bigcatRF(ip,port):
# Connect to h2o
h2o.init(ip,port)
# Training set has 100 categories from cat001 to cat100
# Categories cat001, cat003, ... are perfect predictors of y = 1
# Categories cat002, cat004, ... are perfect predictors of y = 0
#Log.info("Importing bigcat_5000x2.csv data...\n")
bigcat = h2o.import_frame(path=h2o.locate("smalldata/gbm_test/bigcat_5000x2.csv"))
bigcat["y"] = bigcat["y"].asfactor()
#Log.info("Summary of bigcat_5000x2.csv from H2O:\n")
#bigcat.summary()
# Train H2O DRF Model:
#Log.info("H2O DRF (Naive Split) with parameters:\nclassification = TRUE, ntree = 1, depth = 1, nbins = 100, nbins_cats=10\n")
model = h2o.random_forest(x=bigcat[["X"]], y=bigcat["y"], ntrees=1, max_depth=1, nbins=100, nbins_cats=10)
model.show()
if __name__ == "__main__":
h2o.run_test(sys.argv, bigcatRF)
| Add usage of nbins_cats to RF pyunit. | Add usage of nbins_cats to RF pyunit.
| Python | apache-2.0 | spennihana/h2o-3,h2oai/h2o-3,PawarPawan/h2o-v3,mathemage/h2o-3,datachand/h2o-3,mrgloom/h2o-3,printedheart/h2o-3,weaver-viii/h2o-3,weaver-viii/h2o-3,bospetersen/h2o-3,mathemage/h2o-3,h2oai/h2o-3,pchmieli/h2o-3,mathemage/h2o-3,datachand/h2o-3,YzPaul3/h2o-3,ChristosChristofidis/h2o-3,mathemage/h2o-3,mrgloom/h2o-3,madmax983/h2o-3,printedheart/h2o-3,kyoren/https-github.com-h2oai-h2o-3,michalkurka/h2o-3,pchmieli/h2o-3,tarasane/h2o-3,h2oai/h2o-dev,brightchen/h2o-3,pchmieli/h2o-3,ChristosChristofidis/h2o-3,michalkurka/h2o-3,spennihana/h2o-3,weaver-viii/h2o-3,pchmieli/h2o-3,junwucs/h2o-3,mrgloom/h2o-3,junwucs/h2o-3,weaver-viii/h2o-3,datachand/h2o-3,h2oai/h2o-3,jangorecki/h2o-3,mathemage/h2o-3,h2oai/h2o-3,h2oai/h2o-dev,ChristosChristofidis/h2o-3,kyoren/https-github.com-h2oai-h2o-3,h2oai/h2o-3,jangorecki/h2o-3,mrgloom/h2o-3,spennihana/h2o-3,nilbody/h2o-3,mrgloom/h2o-3,nilbody/h2o-3,h2oai/h2o-dev,madmax983/h2o-3,datachand/h2o-3,jangorecki/h2o-3,PawarPawan/h2o-v3,weaver-viii/h2o-3,kyoren/https-github.com-h2oai-h2o-3,PawarPawan/h2o-v3,nilbody/h2o-3,mathemage/h2o-3,tarasane/h2o-3,h2oai/h2o-3,spennihana/h2o-3,jangorecki/h2o-3,tarasane/h2o-3,brightchen/h2o-3,nilbody/h2o-3,YzPaul3/h2o-3,madmax983/h2o-3,michalkurka/h2o-3,PawarPawan/h2o-v3,jangorecki/h2o-3,tarasane/h2o-3,h2oai/h2o-dev,junwucs/h2o-3,printedheart/h2o-3,weaver-viii/h2o-3,datachand/h2o-3,datachand/h2o-3,YzPaul3/h2o-3,tarasane/h2o-3,junwucs/h2o-3,tarasane/h2o-3,printedheart/h2o-3,kyoren/https-github.com-h2oai-h2o-3,pchmieli/h2o-3,jangorecki/h2o-3,jangorecki/h2o-3,YzPaul3/h2o-3,bospetersen/h2o-3,h2oai/h2o-dev,mathemage/h2o-3,printedheart/h2o-3,bospetersen/h2o-3,ChristosChristofidis/h2o-3,bospetersen/h2o-3,bospetersen/h2o-3,pchmieli/h2o-3,brightchen/h2o-3,nilbody/h2o-3,PawarPawan/h2o-v3,brightchen/h2o-3,nilbody/h2o-3,weaver-viii/h2o-3,pchmieli/h2o-3,bospetersen/h2o-3,h2oai/h2o-dev,h2oai/h2o-dev,junwucs/h2o-3,brightchen/h2o-3,michalkurka/h2o-3,madmax983/h2o-3,madmax983/h2o-3,spennihana/h2o-3,junwucs/h2o-3,mrgloom/h2o-3,ChristosChristofidis/h2o-3,kyoren/https-github.com-h2oai-h2o-3,h2oai/h2o-3,YzPaul3/h2o-3,YzPaul3/h2o-3,spennihana/h2o-3,michalkurka/h2o-3,printedheart/h2o-3,YzPaul3/h2o-3,kyoren/https-github.com-h2oai-h2o-3,kyoren/https-github.com-h2oai-h2o-3,mrgloom/h2o-3,ChristosChristofidis/h2o-3,madmax983/h2o-3,printedheart/h2o-3,PawarPawan/h2o-v3,madmax983/h2o-3,nilbody/h2o-3,ChristosChristofidis/h2o-3,datachand/h2o-3,michalkurka/h2o-3,bospetersen/h2o-3,spennihana/h2o-3,brightchen/h2o-3,h2oai/h2o-3,junwucs/h2o-3,michalkurka/h2o-3,brightchen/h2o-3,PawarPawan/h2o-v3,tarasane/h2o-3 |
392af193a2059bd7b25c3014fa8cbdf6fbade032 | pastas/version.py | pastas/version.py | # This is the only location where the version will be written and changed.
# Based on https://packaging.python.org/single_source_version/
__version__ = '0.9.6b'
| # This is the only location where the version will be written and changed.
# Based on https://packaging.python.org/single_source_version/
__version__ = '0.9.5.1'
| Update master branch to 0.9.5.1 | Update master branch to 0.9.5.1
| Python | mit | pastas/pasta,pastas/pastas,gwtsa/gwtsa |
973496ad5111e408ea4832962987098d8c9ca003 | example/example/urls.py | example/example/urls.py | from django.conf.urls import patterns, include, url
from django.contrib import admin
admin.autodiscover()
urlpatterns = patterns('',
# Examples:
# url(r'^$', 'example.views.home', name='home'),
# url(r'^blog/', include('blog.urls')),
url(r'^admin/', include(admin.site.urls)),
)
| from django.conf.urls import patterns, include, url
from django.contrib import admin
admin.autodiscover()
urlpatterns = patterns('',
# Examples:
# url(r'^$', 'example.views.home', name='home'),
# url(r'^blog/', include('blog.urls')),
url(r'^admin/', include(admin.site.urls)),
)
# Add an entry in your URLconf
urlpatterns += patterns("",
#
urlpatterns = patterns('',
(r'^pages/', include('django.contrib.flatpages.urls')),
#
)
| Add an entry in URLconf | Add an entry in URLconf
| Python | mit | dkdndes/django-flatpages-example |
afa3cd7c6e4c82f94eef7edd4bc8db609943226c | api/urls.py | api/urls.py | from django.conf.urls import url
from django.views.generic import TemplateView
from django.contrib.auth.decorators import login_required
from . import views
urlpatterns = [
url(r'^learningcircles/$', views.LearningCircleListView.as_view(), name='api_learningcircles'),
]
| from django.conf.urls import url
from django.views.generic import TemplateView
from django.contrib.auth.decorators import login_required
from . import views
urlpatterns = [
url(r'^learningcircles/$', views.LearningCircleListView.as_view(), name='api_learningcircles'),
url(r'^signup/$', views.SignupView.as_view(), name='api_learningcircles_signup')
]
| Add URL for signup api endpoint | Add URL for signup api endpoint
| Python | mit | p2pu/learning-circles,p2pu/learning-circles,p2pu/learning-circles,p2pu/learning-circles |
f59ac3cc752698ce1755d8953c8771dc978ae6b7 | opendebates/urls.py | opendebates/urls.py | from django.conf.urls import include, url
from django.contrib import admin
urlpatterns = [
url(r'^admin/', include(admin.site.urls)),
url(r'^healthcheck.html$', 'opendebates.views.health_check', name='health_check'),
url(r'^(?P<prefix>[-\w]+)/', include('opendebates.prefixed_urls')),
]
| from django.conf.urls import include, url
from django.contrib import admin
from django.views.generic.base import RedirectView
urlpatterns = [
url(r'^$', RedirectView.as_view(url='https://opendebatecoalition.com', permanent=False)),
url(r'^admin/', include(admin.site.urls)),
url(r'^healthcheck.html$', 'opendebates.views.health_check', name='health_check'),
url(r'^(?P<prefix>[-\w]+)/', include('opendebates.prefixed_urls')),
]
| Add a (temporary) redirect to opendebatecoalition.com from / | Add a (temporary) redirect to opendebatecoalition.com from /
Temporary because permanent is really hard to take back, if you decide
later that you wanted something else.
| Python | apache-2.0 | caktus/django-opendebates,caktus/django-opendebates,caktus/django-opendebates,caktus/django-opendebates |
c6c397dab0e5549ddce59c388dbf0235bc6b44c3 | app/groups/utils.py | app/groups/utils.py | from django.conf import settings
from django.core.mail import EmailMultiAlternatives
from django.template.loader import get_template
from django.template import Context
def send_group_mail(request, to_email, subject, email_text_template, email_html_template):
"""Sends a email to a group of people using a standard layout"""
# Mail the admins to inform them of a new request
ctx = Context({'request': obj})
to_email = group.admins.values_list('email', flat=True)
msg = EmailMultiAlternatives(subject, get_template(email_text_template).render(ctx), getattr(settings, 'DEFAULT_FROM_EMAIL', '[email protected]'), to_email)
msg.attach_alternative(get_template(email_html_template).render(ctx), 'text/html')
mag.send(fail_silently=True)
| from django.conf import settings
from django.core.mail import EmailMultiAlternatives
from django.template.loader import get_template
from django.template import Context
from django.contrib.sites.models import Site
def send_group_email(request, to_email, subject, email_text_template, email_html_template):
"""Sends a email to a group of people using a standard layout"""
# Mail the admins to inform them of a new request
ctx = Context({'request': request, 'domain': Site.objects.get_current().domain})
msg = EmailMultiAlternatives(subject, get_template(email_text_template).render(ctx), getattr(settings, 'DEFAULT_FROM_EMAIL', '[email protected]'), to_email)
msg.attach_alternative(get_template(email_html_template).render(ctx), 'text/html')
msg.send(fail_silently=True)
| Rename the function, and provide the "domain" context for url linking in the emails | Rename the function, and provide the "domain" context for url linking in the emails
| Python | bsd-3-clause | nikdoof/test-auth |
aa0b61b44e631c3a12a16025e93d7e962de23c2f | fabix/system/crontab.py | fabix/system/crontab.py | # coding: utf-8
import fabric.api as fab
import cuisine
def install(filename, user="root", append=False):
"""
Installs crontab from a given cronfile
"""
new_crontab = fab.run("mktemp fabixcron.XXXX")
cuisine.file_upload(new_crontab, filename)
if append is True:
sorted_crontab = fab.run("mktemp fabixcron.XXXX")
# When user have no crontab, then crontab command returns 1 error code
with fab.settings(warn_only=True):
fab.sudo("crontab -u {} -l >> {} 2> /dev/null".format(user, new_crontab))
fab.sudo("sort -u -o {} {}".format(sorted_crontab, new_crontab))
new_crontab = sorted_crontab
fab.sudo("crontab -u {} {}".format(user, new_crontab))
| # coding: utf-8
import fabric.api as fab
import cuisine
def install(filename, user="root", append=False):
"""
Installs crontab from a given cronfile
"""
new_crontab = fab.run("mktemp fabixcron.XXXX")
cuisine.file_upload(new_crontab, filename)
if append is True:
# When user have no crontab, then crontab command returns 1 error code
with fab.settings(warn_only=True):
fab.sudo("crontab -u {} -l 2> /dev/null | awk '!x[$0]++{{print $0}}' >> {}".format(user, new_crontab))
fab.sudo("crontab -u {} {}".format(user, new_crontab))
| Remove duplicate lines from cron file without sorting | Remove duplicate lines from cron file without sorting
| Python | mit | vmalavolta/fabix |
02da417b238256878cfab7c0adef8f86f5532b01 | tamper/randomcomments.py | tamper/randomcomments.py | #!/usr/bin/env python
"""
Copyright (c) 2006-2013 sqlmap developers (http://sqlmap.org/)
See the file 'doc/COPYING' for copying permission
"""
import re
from lib.core.common import randomRange
from lib.core.data import kb
from lib.core.enums import PRIORITY
__priority__ = PRIORITY.LOW
def tamper(payload, **kwargs):
"""
Add random comments to SQL keywords
>>> import random
>>> random.seed(0)
>>> tamper('INSERT')
'I/**/N/**/SERT'
"""
retVal = payload
if payload:
for match in re.finditer(r"[A-Za-z_]+", payload):
word = match.group()
if len(word) < 2:
continue
if word.upper() in kb.keywords:
_ = word[0]
for i in xrange(1, len(word) - 1):
_ += "%s%s" % ("/**/" if randomRange(0, 1) else "", word[i])
_ += word[-1]
retVal = retVal.replace(word, _)
return retVal
| #!/usr/bin/env python
"""
Copyright (c) 2006-2013 sqlmap developers (http://sqlmap.org/)
See the file 'doc/COPYING' for copying permission
"""
import re
from lib.core.common import randomRange
from lib.core.data import kb
from lib.core.enums import PRIORITY
__priority__ = PRIORITY.LOW
def tamper(payload, **kwargs):
"""
Add random comments to SQL keywords
>>> import random
>>> random.seed(0)
>>> tamper('INSERT')
'I/**/N/**/SERT'
"""
retVal = payload
if payload:
for match in re.finditer(r"\b[A-Za-z_]+\b", payload):
word = match.group()
if len(word) < 2:
continue
if word.upper() in kb.keywords:
_ = word[0]
for i in xrange(1, len(word) - 1):
_ += "%s%s" % ("/**/" if randomRange(0, 1) else "", word[i])
_ += word[-1]
if "/**/" not in _:
index = randomRange(1, len(word) - 1)
_ = word[:index] + "/**/" + word[index:]
retVal = retVal.replace(word, _)
return retVal
| Fix for a tamper script (in some cases comments were not inserted) | Fix for a tamper script (in some cases comments were not inserted)
| Python | mit | dtrip/.ubuntu,RexGene/monsu-server,RexGene/monsu-server,dtrip/.ubuntu |
858c029ccadcbdb7365c6f7d28fa426bb11c9ab2 | appengine_config.py | appengine_config.py | # appengine_config.py
from google.appengine.ext import vendor
# Add any libraries install in the "lib" folder.
vendor.add('lib')
import os
if os.environ.get('SERVER_SOFTWARE', '').startswith('Development'):
import imp
import os.path
import inspect
from google.appengine.tools.devappserver2.python import sandbox
sandbox._WHITE_LIST_C_MODULES += ['_ssl', '_socket']
# Use the system socket.
real_os_src_path = os.path.realpath(inspect.getsourcefile(os))
psocket = os.path.join(os.path.dirname(real_os_src_path), 'socket.py')
imp.load_source('socket', psocket)
| # appengine_config.py
from google.appengine.ext import vendor
# Add any libraries install in the "lib" folder.
vendor.add('lib')
import os
if os.environ.get('SERVER_SOFTWARE', '').startswith('Development'):
import imp
import os.path
import inspect
from google.appengine.tools.devappserver2.python.runtime import sandbox
sandbox._WHITE_LIST_C_MODULES += ['_ssl', '_socket']
# Use the system socket.
real_os_src_path = os.path.realpath(inspect.getsourcefile(os))
psocket = os.path.join(os.path.dirname(real_os_src_path), 'socket.py')
imp.load_source('socket', psocket)
| Fix issue with latest sdk: cannot import name sandbox | Fix issue with latest sdk: cannot import name sandbox
| Python | mit | egenerat/flight-manager,egenerat/flight-manager,egenerat/flight-manager,egenerat/flight-manager,egenerat/gae-django,egenerat/gae-django,egenerat/gae-django |
2b758185e0de0d41c5ecc9a5511308ee36c60c91 | Python_Data/smpl4.py | Python_Data/smpl4.py | '''
2.1 - Numpy Array library
'''
#!/usr/bin/env
import numpy as np
def main():
''''
# 1) Create two vectors 'a' and 'b', and sum them.
# Standart
n = 3
a = [x**2 for x in range(1, n + 1)]
b = [x**3 for x in range(1, n + 1)]
v = plainVectorAddition(a, b)
# Numpy
n = 3
a = np.arange(1, n + 1) ** 2
b = np.arange(1, n + 1) ** 3
v = npSum(a, b)
'''
print(v)
def plainSum(a, b):
'''
Sum two vectors using standart python functions
'''
return [i + j for i,j in zip(a,b)]
def npSum(a, b):
return a + b
if __name__ == '__main__':
main()
| '''
2.1 - Numpy Array library
- Sum of two vectors -
Usage: python smpl4.py n
Where 'n' specifies the size of the vector.
The program make performance comparisons and print the results.
'''
#!/usr/bin/env
import numpy as np
import sys
from datetime import datetime
def main():
size = int(sys.argv[1])
start = datetime.now()
v = plainSum(size)
delta = datetime.now() - start
print("plainSum() - elapsed time: ",delta)
start = datetime.now()
v = npSum(size)
delta = datetime.now() - start
print("npSum() - elapsed time: ",delta)
''''
# 1) Create two vectors 'a' and 'b', and sum them.
# Standart
size = int(sys.argv[1])
v = plainVectorAddition(a, b)
# Numpy
size = int(sys.argv[1])
v = npSum(a, b)
'''
#print(v)
def plainSum(n):
'''
Sum two vectors using standart python functions
'''
a = [x**2 for x in range(1, n + 1)]
b = [x**3 for x in range(1, n + 1)]
return [i + j for i,j in zip(a,b)]
def npSum(n):
'''
Sum two vectors using numpy functions
'''
a = np.arange(1, n + 1) ** 2
b = np.arange(1, n + 1) ** 3
return a + b
if __name__ == '__main__':
main()
| Add file with linear algebra numpy operations | Add file with linear algebra numpy operations
| Python | unlicense | robotenique/RandomAccessMemory,robotenique/RandomAccessMemory,robotenique/RandomAccessMemory |
b83acdc08ed0211c8b53d8f8a158c4ac43c8587c | test/test_issue655.py | test/test_issue655.py | from rdflib import Graph, Namespace, URIRef, Literal
from rdflib.compare import to_isomorphic
import unittest
class TestIssue655(unittest.TestCase):
def test_issue655(self):
PROV = Namespace('http://www.w3.org/ns/prov#')
bob = URIRef("http://example.org/object/Bob")
value = Literal(float("inf"))
# g1 is a simple graph with one attribute having an infinite value
g1 = Graph()
g1.add((bob, PROV.value, value))
# Build g2 out of the deserialisation of g1 serialisation
g2 = Graph()
g2.parse(data=g1.serialize(format='turtle'), format='turtle')
self.assertTrue(g1.serialize(
format='turtle') == g2.serialize(format='turtle'))
self.assertTrue(to_isomorphic(g1) == to_isomorphic(g2))
self.assertTrue(Literal(float("inf")).n3().split("^")[0] == '"INF"')
self.assertTrue(Literal(float("-inf")).n3().split("^")[0] == '"-INF"')
if __name__ == "__main__":
unittest.main()
| from rdflib import Graph, Namespace, URIRef, Literal
from rdflib.compare import to_isomorphic
import unittest
class TestIssue655(unittest.TestCase):
def test_issue655(self):
PROV = Namespace('http://www.w3.org/ns/prov#')
bob = URIRef("http://example.org/object/Bob")
value = Literal(float("inf"))
# g1 is a simple graph with one attribute having an infinite value
g1 = Graph()
g1.add((bob, PROV.value, value))
# Build g2 out of the deserialisation of g1 serialisation
g2 = Graph()
g2.parse(data=g1.serialize(format='turtle'), format='turtle')
self.assertTrue(to_isomorphic(g1) == to_isomorphic(g2))
self.assertTrue(Literal(float("inf")).n3().split("^")[0] == '"INF"')
self.assertTrue(Literal(float("-inf")).n3().split("^")[0] == '"-INF"')
if __name__ == "__main__":
unittest.main()
| Remove test on serialisation (order is not fixed) | Remove test on serialisation (order is not fixed)
| Python | bsd-3-clause | RDFLib/rdflib,RDFLib/rdflib,RDFLib/rdflib,RDFLib/rdflib |
1fe790a152d2397a4437a791bdb60db2aa823589 | tests/test_load_model.py | tests/test_load_model.py | """Test GitHub issue #4.
Diagram could not be loaded due to JuggleError (presumed cyclic
resolving of diagram items).
"""
from gi.repository import GLib, Gtk
from gaphor.storage.storage import load
class TestCyclicDiagram:
def test_bug(self, case, test_models):
"""Load file.
This does not nearly resemble the error, since the model should
be loaded from within the mainloop (which will delay all
updates).
"""
path = test_models / "dbus.gaphor"
load(path, case.element_factory, case.modeling_language)
def test_bug_idle(self, case, test_models):
"""Load file in gtk main loop.
This does not nearly resemble the error, since the model should
be loaded from within the mainloop (which will delay all
updates).
"""
def handler():
try:
path = test_models / "dbus.gaphor"
load(path, case.element_factory, case.modeling_language)
finally:
Gtk.main_quit()
assert GLib.timeout_add(1, handler) > 0
Gtk.main()
| # flake8: noqa F401,F811
"""Diagram could not be loaded due to JuggleError (presumed cyclic resolving of
diagram items)."""
from gi.repository import GLib, Gtk
from gaphor.diagram.tests.fixtures import (
element_factory,
event_manager,
modeling_language,
)
from gaphor.storage.storage import load
def test_cyclic_diagram_bug(element_factory, modeling_language, test_models):
"""Load file.
This does not nearly resemble the error, since the model should be
loaded from within the mainloop (which will delay all updates).
"""
path = test_models / "dbus.gaphor"
load(path, element_factory, modeling_language)
def test_cyclic_diagram_bug_idle(element_factory, modeling_language, test_models):
"""Load file in gtk main loop.
This does not nearly resemble the error, since the model should be
loaded from within the mainloop (which will delay all updates).
"""
def handler():
try:
path = test_models / "dbus.gaphor"
load(path, element_factory, modeling_language)
finally:
Gtk.main_quit()
assert GLib.timeout_add(1, handler) > 0
Gtk.main()
| Convert load_model tests to pytest functions | Convert load_model tests to pytest functions
| Python | lgpl-2.1 | amolenaar/gaphor,amolenaar/gaphor |
8b7aef341aadefb859790684f41453f561813083 | tmi/views/__init__.py | tmi/views/__init__.py | from flask import g
from flask.ext.login import current_user
from tmi.core import app
from tmi.assets import assets # noqa
from tmi.views.ui import ui # noqa
from tmi.views.auth import login, logout # noqa
from tmi.views.admin import admin # noqa
from tmi.views.cards_api import blueprint as cards_api
@app.before_request
def before_request():
g.user = current_user
app.register_blueprint(cards_api)
| from flask import g, request
from flask.ext.login import current_user
from werkzeug.exceptions import HTTPException
from tmi.core import app
from tmi.forms import Invalid
from tmi.util import jsonify
from tmi.assets import assets # noqa
from tmi.views.ui import ui # noqa
from tmi.views.auth import login, logout # noqa
from tmi.views.admin import admin # noqa
from tmi.views.cards_api import blueprint as cards_api
@app.before_request
def before_request():
g.user = current_user
app.register_blueprint(cards_api)
@app.errorhandler(401)
@app.errorhandler(403)
@app.errorhandler(404)
@app.errorhandler(410)
@app.errorhandler(500)
def handle_exceptions(exc):
if isinstance(exc, HTTPException):
message = exc.get_description(request.environ)
message = message.replace('<p>', '').replace('</p>', '')
body = {
'status': exc.code,
'name': exc.name,
'message': message
}
headers = exc.get_headers(request.environ)
else:
body = {
'status': 500,
'name': exc.__class__.__name__,
'message': unicode(exc)
}
headers = {}
return jsonify(body, status=body.get('status'),
headers=headers)
@app.errorhandler(Invalid)
def handle_invalid(exc):
body = {
'status': 400,
'name': 'Invalid Data',
'message': unicode(exc),
'errors': exc.asdict()
}
return jsonify(body, status=400)
| Handle errors with JSON messages. | Handle errors with JSON messages. | Python | mit | pudo/storyweb,pudo/storyweb |
f5f728074b257aac371fc59af8de02e440e57819 | furikura/desktop/unity.py | furikura/desktop/unity.py | import gi
gi.require_version('Unity', '7.0')
from gi.repository import Unity, Dbusmenu
launcher = Unity.LauncherEntry.get_for_desktop_id("furikura.desktop")
def update_counter(count):
launcher.set_property("count", count)
launcher.set_property("count_visible", True)
def add_quicklist_item(item):
quick_list = Dbusmenu.Menuitem.new()
list_item = Dbusmenu.Menuitem.new()
list_item.property_set(Dbusmenu.MENUITEM_PROP_LABEL, item)
list_item.property_set_bool(Dbusmenu.MENUITEM_PROP_VISIBLE, True)
quick_list.child_append(list_item)
launcher.set_property("quicklist", quick_list) | import gi
from threading import Timer
gi.require_version('Unity', '7.0')
from gi.repository import Unity, Dbusmenu
launcher = Unity.LauncherEntry.get_for_desktop_id("furikura.desktop")
def update_counter(count):
launcher.set_property("count", count)
launcher.set_property("count_visible", True)
if count > 0:
launcher.set_property("urgent", True)
timer = Timer(3, launcher.set_property, ['urgent', False])
timer.start()
def add_quicklist_item(item):
quick_list = Dbusmenu.Menuitem.new()
list_item = Dbusmenu.Menuitem.new()
list_item.property_set(Dbusmenu.MENUITEM_PROP_LABEL, item)
list_item.property_set_bool(Dbusmenu.MENUITEM_PROP_VISIBLE, True)
quick_list.child_append(list_item)
launcher.set_property("quicklist", quick_list) | Apply "Urgent" icon animation on new message | Apply "Urgent" icon animation on new message
| Python | mit | benjamindean/furi-kura,benjamindean/furi-kura |
a02258643b4109ba862f8f927a8a2612b81c2a36 | ghtools/command/browse.py | ghtools/command/browse.py | from __future__ import print_function
import json
from argh import ArghParser, arg
from ghtools import cli
from ghtools.api import GithubAPIClient
parser = ArghParser(description="Browse the GitHub API")
@arg('github', nargs='?', help='GitHub instance nickname (e.g "enterprise")')
@arg('url', help='URL to browse')
@arg('-m', '--method', default='get', choices=('get', 'delete'), help='HTTP method to use.')
def browse(args):
"""
Print the GitHub API response at the given URL
"""
with cli.catch_api_errors():
client = GithubAPIClient(nickname=args.github)
res = client.request(args.method, args.url, _raise=False)
print('HTTP/1.1 {0} {1}'.format(res.status_code, res.reason))
for k, v in res.headers.items():
print("{0}: {1}".format(k, v))
print()
if res.json() is not None:
print(json.dumps(res.json, indent=2))
else:
print(res.content)
parser.set_default_command(browse)
def main():
parser.dispatch()
if __name__ == '__main__':
main()
| from __future__ import print_function
import json
from argh import ArghParser, arg
from ghtools import cli
from ghtools.api import GithubAPIClient
parser = ArghParser(description="Browse the GitHub API")
@arg('github', nargs='?', help='GitHub instance nickname (e.g "enterprise")')
@arg('url', help='URL to browse')
@arg('-m', '--method', default='get', choices=('get', 'delete'), help='HTTP method to use.')
def browse(args):
"""
Print the GitHub API response at the given URL
"""
with cli.catch_api_errors():
client = GithubAPIClient(nickname=args.github)
res = client.request(args.method, args.url, _raise=False)
print('HTTP/1.1 {0} {1}'.format(res.status_code, res.reason))
for k, v in res.headers.items():
print("{0}: {1}".format(k, v))
print()
if res.json() is not None:
print(json.dumps(res.json(), indent=2))
else:
print(res.content)
parser.set_default_command(browse)
def main():
parser.dispatch()
if __name__ == '__main__':
main()
| Add missed json to json() tweak | Add missed json to json() tweak
| Python | mit | alphagov/ghtools |
3b5ad132f3670d1c1210190ecd7b41a379fbd10e | trakt/core/helpers.py | trakt/core/helpers.py | import arrow
def to_datetime(value):
if value is None:
return None
# Parse ISO8601 datetime
dt = arrow.get(value)
# Return python datetime object
return dt.datetime
| import arrow
def to_datetime(value):
if value is None:
return None
# Parse ISO8601 datetime
dt = arrow.get(value)
# Convert to UTC
dt = dt.to('UTC')
# Return naive datetime object
return dt.naive
| Convert all datetime properties to UTC | Convert all datetime properties to UTC
| Python | mit | shad7/trakt.py,fuzeman/trakt.py |
5e3b712c4c2eac7227d6e894ce05db6f1ede074a | hgtools/tests/conftest.py | hgtools/tests/conftest.py | import os
import pytest
from hgtools import managers
def _ensure_present(mgr):
try:
mgr.version()
except Exception:
pytest.skip()
@pytest.fixture
def hg_repo(tmpdir):
tmpdir.chdir()
mgr = managers.MercurialManager()
_ensure_present(mgr)
mgr._invoke('init', '.')
os.makedirs('bar')
touch('bar/baz')
mgr._invoke('addremove')
mgr._invoke('ci', '-m', 'committed')
with open('bar/baz', 'w') as baz:
baz.write('content')
mgr._invoke('ci', '-m', 'added content')
return tmpdir
@pytest.fixture
def git_repo(tmpdir):
tmpdir.chdir()
mgr = managers.GitManager()
_ensure_present(mgr)
mgr._invoke('init')
mgr._invoke('config', 'user.email', '[email protected]')
mgr._invoke('config', 'user.name', 'HGTools')
os.makedirs('bar')
touch('bar/baz')
mgr._invoke('add', '.')
mgr._invoke('commit', '-m', 'committed')
with open('bar/baz', 'w') as baz:
baz.write('content')
mgr._invoke('commit', '-am', 'added content')
return tmpdir
def touch(filename):
with open(filename, 'a'):
pass
| import os
import pytest
from hgtools import managers
def _ensure_present(mgr):
try:
mgr.version()
except Exception:
pytest.skip()
@pytest.fixture
def tmpdir_as_cwd(tmpdir):
with tmpdir.as_cwd():
yield tmpdir
@pytest.fixture
def hg_repo(tmpdir_as_cwd):
mgr = managers.MercurialManager()
_ensure_present(mgr)
mgr._invoke('init', '.')
os.makedirs('bar')
touch('bar/baz')
mgr._invoke('addremove')
mgr._invoke('ci', '-m', 'committed')
with open('bar/baz', 'w') as baz:
baz.write('content')
mgr._invoke('ci', '-m', 'added content')
return tmpdir_as_cwd
@pytest.fixture
def git_repo(tmpdir_as_cwd):
mgr = managers.GitManager()
_ensure_present(mgr)
mgr._invoke('init')
mgr._invoke('config', 'user.email', '[email protected]')
mgr._invoke('config', 'user.name', 'HGTools')
os.makedirs('bar')
touch('bar/baz')
mgr._invoke('add', '.')
mgr._invoke('commit', '-m', 'committed')
with open('bar/baz', 'w') as baz:
baz.write('content')
mgr._invoke('commit', '-am', 'added content')
return tmpdir_as_cwd
def touch(filename):
with open(filename, 'a'):
pass
| Fix test failures by restoring working directory in fixtures. | Fix test failures by restoring working directory in fixtures.
| Python | mit | jaraco/hgtools |
f953a5e6b52301defc3aee1f191507ed7005caa1 | azurerm/restfns.py | azurerm/restfns.py | # restfns - REST functions for azurerm
import requests
# do_get(endpoint, access_token)
# do an HTTP GET request and return JSON
def do_get(endpoint, access_token):
headers = {"Authorization": 'Bearer ' + access_token}
return requests.get(endpoint, headers=headers).json()
# do_delete(endpoint, access_token)
# do an HTTP GET request and return JSON
def do_delete(endpoint, access_token):
headers = {"Authorization": 'Bearer ' + access_token}
return requests.delete(endpoint, headers=headers)
# do_put(endpoint, body, access_token)
# do an HTTP PUT request and return JSON
def do_put(endpoint, body, access_token):
headers = {"content-type": "application/json", "Authorization": 'Bearer ' + access_token}
return requests.put(endpoint, data=body, headers=headers)
# do_put(endpoint, body, access_token)
# do an HTTP PUT request and return JSON
def do_post(endpoint, body, access_token):
headers = {"content-type": "application/json", "Authorization": 'Bearer ' + access_token}
return requests.post(endpoint, data=body, headers=headers) | # restfns - REST functions for azurerm
import requests
# do_get(endpoint, access_token)
# do an HTTP GET request and return JSON
def do_get(endpoint, access_token):
headers = {"Authorization": 'Bearer ' + access_token}
return requests.get(endpoint, headers=headers).json()
# do_delete(endpoint, access_token)
# do an HTTP GET request and return JSON
def do_delete(endpoint, access_token):
headers = {"Authorization": 'Bearer ' + access_token}
return requests.delete(endpoint, headers=headers)
# do_put(endpoint, body, access_token)
# do an HTTP PUT request and return JSON
def do_put(endpoint, body, access_token):
headers = {"content-type": "application/json", "Authorization": 'Bearer ' + access_token}
return requests.put(endpoint, data=body, headers=headers)
# do_post(endpoint, body, access_token)
# do an HTTP POST request and return JSON
def do_post(endpoint, body, access_token):
headers = {"content-type": "application/json", "Authorization": 'Bearer ' + access_token}
return requests.post(endpoint, data=body, headers=headers) | Fix REST function comments for POST | Fix REST function comments for POST
| Python | mit | gbowerman/azurerm |
cf83c92ee2160a9d27d18347137b55b4a111228d | zvm/zcpu.py | zvm/zcpu.py | #
# A class which represents the CPU itself, the brain of the virtual
# machine. It ties all the systems together and runs the story.
#
# For the license of this file, please consult the LICENSE file in the
# root directory of this distribution.
#
class ZCpuError(Exception):
"General exception for Zcpu class"
pass
class ZCpu(object):
def __init__(self, zmem):
""
self._memory = zmem
self._opcode_handlers = {}
# Introspect ourselves, discover all functions that look like
# opcode handlers, and add them to our mapper
for func in self.__class__.__dict__:
print "Considering %s" % func
instance_func = getattr(self, func)
if instance_func != None:
doc_head = instance_func.__doc__.split('\n')[0]
print "Potential candidate, docstring is %s" % doc_head
if doc_head.startswith("ZOPCODE "):
opcode_num = int(doc_head[8:], 16)
self._opcode_handlers[opcode_num] = instance_func
print self._opcode_handlers
def test_opcode(self, zop):
"""ZOPCODE 0x20
This is a test opcode."""
| #
# A class which represents the CPU itself, the brain of the virtual
# machine. It ties all the systems together and runs the story.
#
# For the license of this file, please consult the LICENSE file in the
# root directory of this distribution.
#
class ZCpuError(Exception):
"General exception for Zcpu class"
pass
class ZCpu(object):
_opcodes = {}
def __init__(self, zmem):
self._memory = zmem
print self._opcodes
def _get_handler(self, opcode):
return getattr(self, _opcodes[opcode])
def test_opcode(self, zop):
"""This is a test opcode."""
test_opcode._opcode = 0x20
# This is the "automagic" opcode handler registration system.
# After each function that is an opcode handler, we assign the
# function object an _opcode attribute, giving the numeric opcode
# the function implements.
#
# Then, the following code iterates back over all items in the
# class, and registers all objects with that attribute in the
# _opcodes dictionary.
#
# Then, at runtime, the _get_handler method can be invoked to
# retrieve the function implementing a given opcode. Pretty cool
# voodoo if you ask me.
for k,v in vars().items():
if hasattr(v, "_opcode"):
_opcodes[v._opcode] = k
| Make the CPU use lovely decorator syntax for registering opcode implementations. | Make the CPU use lovely decorator syntax for registering opcode implementations.
| Python | bsd-3-clause | sussman/zvm,sussman/zvm |
e5b98d072017c8a70cf033cdb34233b2d0a56b2e | pyfirmata/boards.py | pyfirmata/boards.py | BOARDS = {
'arduino': {
'digital': tuple(x for x in range(14)),
'analog': tuple(x for x in range(6)),
'pwm': (3, 5, 6, 9, 10, 11),
'use_ports': True,
'disabled': (0, 1) # Rx, Tx, Crystal
},
'arduino_mega': {
'digital': tuple(x for x in range(54)),
'analog': tuple(x for x in range(16)),
'pwm': tuple(x for x in range(2, 14)),
'use_ports': True,
'disabled': (0, 1) # Rx, Tx, Crystal
},
'arduino_due': {
'digital': tuple(x for x in range(54)),
'analog': tuple(x for x in range(12)),
'pwm': tuple(x for x in range(2, 14)),
'use_ports': True,
'disabled': (0, 1) # Rx, Tx, Crystal
},
'nano': {
'digital': tuple(x for x in range(14)),
'analog': tuple(x for x in range(8)),
'pwm': (3, 5, 6, 9, 10, 11),
'use_ports': True,
'disabled': (0, 1) # Rx, Tx, Crystal
}
}
| BOARDS = {
'arduino': {
'digital': tuple(x for x in range(14)),
'analog': tuple(x for x in range(6)),
'pwm': (3, 5, 6, 9, 10, 11),
'use_ports': True,
'disabled': (0, 1) # Rx, Tx, Crystal
},
'arduino_mega': {
'digital': tuple(x for x in range(54)),
'analog': tuple(x for x in range(16)),
'pwm': tuple(x for x in range(2, 14)),
'use_ports': True,
'disabled': (0, 1) # Rx, Tx, Crystal
},
'arduino_due': {
'digital': tuple(x for x in range(54)),
'analog': tuple(x for x in range(12)),
'pwm': tuple(x for x in range(2, 14)),
'use_ports': True,
'disabled': (0, 1) # Rx, Tx, Crystal
},
'arduino_nano': {
'digital': tuple(x for x in range(14)),
'analog': tuple(x for x in range(8)),
'pwm': (3, 5, 6, 9, 10, 11),
'use_ports': True,
'disabled': (0, 1) # Rx, Tx, Crystal
}
}
| Correct class name of arduino nano | Correct class name of arduino nano
| Python | mit | JoseU/pyFirmata,tino/pyFirmata |
c2eccb4ce1259830dd641d19624358af83c09549 | webcomix/comic_spider.py | webcomix/comic_spider.py | from urllib.parse import urljoin
import scrapy
class ComicSpider(scrapy.Spider):
name = "My spider"
def __init__(self, *args, **kwargs):
self.start_urls = kwargs.get('start_urls') or []
self.next_page_selector = kwargs.get('next_page_selector', None)
self.comic_image_selector = kwargs.get('comic_image_selector', None)
super(ComicSpider, self).__init__(*args, **kwargs)
def parse(self, response):
comic_image_url = response.xpath(
self.comic_image_selector).extract_first()
page = response.meta.get('page') or 1
yield {
"image_element": urljoin(response.url, comic_image_url),
"page": page
}
next_page_url = response.xpath(self.next_page_selector).extract_first()
if next_page_url is not None and not next_page_url.endswith('#'):
yield scrapy.Request(
response.urljoin(next_page_url), meta={'page': page + 1})
| from urllib.parse import urljoin
import click
import scrapy
class ComicSpider(scrapy.Spider):
name = "Comic Spider"
def __init__(self, *args, **kwargs):
self.start_urls = kwargs.get('start_urls') or []
self.next_page_selector = kwargs.get('next_page_selector', None)
self.comic_image_selector = kwargs.get('comic_image_selector', None)
super(ComicSpider, self).__init__(*args, **kwargs)
def parse(self, response):
click.echo("Downloading page {}".format(response.url))
comic_image_url = response.xpath(
self.comic_image_selector).extract_first()
page = response.meta.get('page') or 1
if comic_image_url is not None:
yield {
"image_element": urljoin(response.url, comic_image_url),
"page": page
}
else:
click.echo("Could not find comic image.")
next_page_url = response.xpath(self.next_page_selector).extract_first()
if next_page_url is not None and not next_page_url.endswith('#'):
yield scrapy.Request(
response.urljoin(next_page_url), meta={'page': page + 1})
| Copy logging from previous version and only yield item to pipeline if a comic image was found | Copy logging from previous version and only yield item to pipeline if a comic image was found
| Python | mit | J-CPelletier/webcomix,J-CPelletier/webcomix,J-CPelletier/WebComicToCBZ |
e1c9828354036279469260ab498d8c979baa1562 | code/get_licenses.py | code/get_licenses.py | #!/usr/bin/python
import requests
import json
import csv
import sys
def parse_dataset_metadata(dataset):
if 'rights' in dataset.keys():
rights = dataset['rights'].encode('utf-8').strip()
rights = rights.replace("\n", "")
else:
rights = 'not supplied'
return [dataset['key'].encode('utf-8'), rights]
def get_gbif_datasets(limit, offset):
params = {'limit': limit, 'offset': offset}
r = requests.get('http://api.gbif.org/v0.9/dataset/', params=params)
request_result = r.json()['results']
return request_result
results = []
more_results_to_find = True
offset = 0
limit = 20
print '"#dataset-key","rights"'
csvwriter = csv.writer(sys.stdout)
while more_results_to_find:
datasets = get_gbif_datasets(limit, offset)
for dataset in datasets:
csvwriter.writerow(parse_dataset_metadata(dataset))
offset += 20
if len(datasets) == 0:
more_results_to_find = False
| #!/usr/bin/python
import requests
import json
import csv
import sys
def parse_dataset_metadata(dataset):
if 'rights' in dataset.keys():
rights = dataset['rights'].encode('utf-8').strip()
rights = rights.replace("\n", "")
else:
rights = 'not supplied'
return [dataset['key'].encode('utf-8'), rights]
def get_gbif_datasets(limit, offset):
params = {'limit': limit, 'offset': offset}
r = requests.get('http://api.gbif.org/v0.9/dataset/', params=params)
request_result = r.json()['results']
return request_result
results = []
more_results_to_find = True
offset = 0
limit = 20
print '#dataset-key,rights'
csvwriter = csv.writer(sys.stdout)
while more_results_to_find:
datasets = get_gbif_datasets(limit, offset)
for dataset in datasets:
csvwriter.writerow(parse_dataset_metadata(dataset))
offset += 20
if len(datasets) == 0:
more_results_to_find = False
| Remove quotes from header line | Remove quotes from header line
| Python | mit | Datafable/gbif-data-licenses,Datafable/gbif-data-licenses,Datafable/gbif-data-licenses |
1a6344ea1fac51a8024e1803a0391662d4ab81e0 | pyeda/boolalg/vexpr.py | pyeda/boolalg/vexpr.py | """
Boolean Vector Logic Expressions
This module is deprecated.
The functionality has been superceded by the bfarray module.
Interface Functions:
bitvec
"""
from pyeda.boolalg import expr
from pyeda.boolalg import bfarray
def bitvec(name, *dims):
"""Return a new array of given dimensions, filled with Expressions.
Parameters
----------
name : str
dims : (int or (int, int))
An int N means a slice from [0:N]
A tuple (M, N) means a slice from [M:N]
"""
if dims:
return bfarray.exprvars(name, *dims)
else:
return expr.exprvar(name)
| """
Boolean Vector Logic Expressions
This module is deprecated.
The functionality has been superceded by the bfarray module.
Interface Functions:
bitvec
"""
from warnings import warn
from pyeda.boolalg import expr
from pyeda.boolalg import bfarray
def bitvec(name, *dims):
"""Return a new array of given dimensions, filled with Expressions.
Parameters
----------
name : str
dims : (int or (int, int))
An int N means a slice from [0:N]
A tuple (M, N) means a slice from [M:N]
"""
warn("The 'bitvec' function is deprecated. Use 'exprvars' instead.")
if dims:
return bfarray.exprvars(name, *dims)
else:
return expr.exprvar(name)
| Add deprecation warning to bitvec function | Add deprecation warning to bitvec function
| Python | bsd-2-clause | pombredanne/pyeda,GtTmy/pyeda,karissa/pyeda,sschnug/pyeda,sschnug/pyeda,cjdrake/pyeda,sschnug/pyeda,cjdrake/pyeda,GtTmy/pyeda,GtTmy/pyeda,karissa/pyeda,pombredanne/pyeda,karissa/pyeda,cjdrake/pyeda,pombredanne/pyeda |
2339fa64974184c8174917be305c45a34013bae9 | easy/lowest_unique/lowest_unique.py | easy/lowest_unique/lowest_unique.py | import sys
def lowest_unique(int_list):
numbers = {}
for index in range(len(int_list)):
group = numbers.setdefault(int(int_list[index]), [])
group.append(index)
for number in numbers:
retval = numbers[number]
if len(retval) == 1:
return retval[0] + 1
return 0
if __name__ == '__main__':
inputfile = sys.argv[1]
with open(inputfile, 'r') as f:
for line in f:
line_list = line.rstrip().split()
if line_list:
print str(lowest_unique(line_list))
| import sys
def lowest_unique(int_list):
numbers = {}
for index, number in enumerate(int_list):
group = numbers.setdefault(int(number), [])
group.append(index)
for number in sorted(numbers.keys()):
retval = numbers[number]
if len(retval) == 1:
return retval[0] + 1
return 0
if __name__ == '__main__':
inputfile = sys.argv[1]
with open(inputfile, 'r') as f:
for line in f:
line_list = line.rstrip().split()
if line_list:
print str(lowest_unique(line_list))
| Improve solution by using enumerate | Improve solution by using enumerate
| Python | mit | MikeDelaney/CodeEval |
a5faf69efd3a53b937b0bd27d42ad0ca8b0af9a9 | centinel/backend.py | centinel/backend.py | import requests
import config
def request(slug):
url = "%s%s" % (config.server_url, slug)
req = requests.get(url)
if req.status_code != requests.codes.ok:
raise req.raise_for_status()
return req.json()
def get_recommended_versions():
return request("/versions")
def get_experiments():
return request("/experiments")
def get_results():
return request("/results")
def get_clients():
return request("/clients")
def request(slug):
url = "%s%s" % (config.server_url, slug)
req = requests.get(url)
return req.json()
| import requests
import config
def request(slug):
url = "%s%s" % (config.server_url, slug)
req = requests.get(url)
if req.status_code != requests.codes.ok:
raise req.raise_for_status()
return req.json()
def get_recommended_versions():
return request("/versions")
def get_experiments():
return request("/experiments")
def get_results():
return request("/results")
def get_clients():
return request("/clients")
def submit_result(file_name):
with open(file_name) as result_file:
file = {'result' : result_file}
url = "%s%s" % (config.server_url, "/results")
requests.post(url, files=file)
if req.status_code != requests.codes.ok:
raise req.raise_for_status()
| Add ability to submit results | Add ability to submit results
| Python | mit | iclab/centinel,JASONews/centinel,lianke123321/centinel,Ashish1805/centinel,lianke123321/centinel,iclab/centinel,iclab/centinel,ben-jones/centinel,rpanah/centinel,lianke123321/centinel,rpanah/centinel,rpanah/centinel |
de4f395d75d7307a79d8db44399a6feaa0118c0a | wrappers/python/setup.py | wrappers/python/setup.py | from distutils.core import setup
setup(
name='python3-indy',
version='1.6.1',
packages=['indy'],
url='https://github.com/hyperledger/indy-sdk',
license='MIT/Apache-2.0',
author='Vyacheslav Gudkov',
author_email='[email protected]',
description='This is the official SDK for Hyperledger Indy (https://www.hyperledger.org/projects), which provides a distributed-ledger-based foundation for self-sovereign identity (https://sovrin.org). The major artifact of the SDK is a c-callable library.',
install_requires=['pytest', 'pytest-asyncio', 'base58'],
tests_require=['pytest', 'pytest-asyncio', 'base58']
)
| from distutils.core import setup
setup(
name='python3-indy',
version='1.6.1',
packages=['indy'],
url='https://github.com/hyperledger/indy-sdk',
license='MIT/Apache-2.0',
author='Vyacheslav Gudkov',
author_email='[email protected]',
description='This is the official SDK for Hyperledger Indy (https://www.hyperledger.org/projects), which provides a distributed-ledger-based foundation for self-sovereign identity (https://sovrin.org). The major artifact of the SDK is a c-callable library.',
install_requires=['pytest<3.7', 'pytest-asyncio', 'base58'],
tests_require=['pytest<3.7', 'pytest-asyncio', 'base58']
)
| Fix pytest version in python wrapper deps. | Fix pytest version in python wrapper deps.
Signed-off-by: Sergey Minaev <[email protected]>
| Python | apache-2.0 | anastasia-tarasova/indy-sdk,peacekeeper/indy-sdk,Artemkaaas/indy-sdk,srottem/indy-sdk,anastasia-tarasova/indy-sdk,Artemkaaas/indy-sdk,peacekeeper/indy-sdk,peacekeeper/indy-sdk,anastasia-tarasova/indy-sdk,srottem/indy-sdk,peacekeeper/indy-sdk,srottem/indy-sdk,peacekeeper/indy-sdk,srottem/indy-sdk,anastasia-tarasova/indy-sdk,srottem/indy-sdk,srottem/indy-sdk,peacekeeper/indy-sdk,peacekeeper/indy-sdk,anastasia-tarasova/indy-sdk,Artemkaaas/indy-sdk,anastasia-tarasova/indy-sdk,Artemkaaas/indy-sdk,Artemkaaas/indy-sdk,anastasia-tarasova/indy-sdk,peacekeeper/indy-sdk,peacekeeper/indy-sdk,Artemkaaas/indy-sdk,Artemkaaas/indy-sdk,peacekeeper/indy-sdk,anastasia-tarasova/indy-sdk,anastasia-tarasova/indy-sdk,anastasia-tarasova/indy-sdk,Artemkaaas/indy-sdk,srottem/indy-sdk,srottem/indy-sdk,srottem/indy-sdk,peacekeeper/indy-sdk,srottem/indy-sdk,Artemkaaas/indy-sdk,Artemkaaas/indy-sdk,Artemkaaas/indy-sdk,peacekeeper/indy-sdk,Artemkaaas/indy-sdk,srottem/indy-sdk,srottem/indy-sdk,anastasia-tarasova/indy-sdk,anastasia-tarasova/indy-sdk,srottem/indy-sdk,peacekeeper/indy-sdk,Artemkaaas/indy-sdk,anastasia-tarasova/indy-sdk |
cd621061773b7eafcea9358c9b762663a070ccc5 | cc/license/jurisdiction.py | cc/license/jurisdiction.py | import RDF
import zope.interface
import interfaces
import rdf_helper
class Jurisdiction(object):
zope.interface.implements(interfaces.IJurisdiction)
def __init__(self, short_name):
'''@param short_name can be e.g. mx'''
model = rdf_helper.init_model(
rdf_helper.JURI_RDF_PATH)
self.code = short_name
self.id = 'http://creativecommons.org/international/%s/' % short_name
id_uri = RDF.Uri(self.id)
self.local_url = rdf_helper.query_to_single_value(model,
id_uri, RDF.Uri(rdf_helper.NS_CC + 'jurisdictionSite'), None)
self.launched = rdf_helper.query_to_single_value(model,
id_uri, RDF.Uri(rdf_helper.NS_CC + 'launched'), None)
| import RDF
import zope.interface
import interfaces
import rdf_helper
class Jurisdiction(object):
zope.interface.implements(interfaces.IJurisdiction)
def __init__(self, short_name):
"""Creates an object representing a jurisdiction.
short_name is a (usually) two-letter code representing
the same jurisdiction; for a complete list, see
cc.license.jurisdiction_codes()"""
model = rdf_helper.init_model(
rdf_helper.JURI_RDF_PATH)
self.code = short_name
self.id = 'http://creativecommons.org/international/%s/' % short_name
id_uri = RDF.Uri(self.id)
try:
self.local_url = rdf_helper.query_to_single_value(model,
id_uri, RDF.Uri(rdf_helper.NS_CC + 'jurisdictionSite'), None)
except rdf_helper.NoValuesFoundException:
self.local_url = None
try:
self.launched = rdf_helper.query_to_single_value(model,
id_uri, RDF.Uri(rdf_helper.NS_CC + 'launched'), None)
except rdf_helper.NoValuesFoundException:
self.launched = None
| Add documentation and make Jurisdiction calls not fail when some of the values aren't found. | Add documentation and make Jurisdiction calls not fail when some of the values aren't found.
| Python | mit | creativecommons/cc.license,creativecommons/cc.license |
d8f1b1151ff917cad924bd6f8fac330602c259c9 | warreport/__main__.py | warreport/__main__.py | import asyncio
import logging
from warreport import battle_monitor, battle_reporting
logger = logging.getLogger("warreport")
def main():
logger.info("Starting main loop.")
logger.debug("Debug logging enabled.")
loop = asyncio.get_event_loop()
loop.run_until_complete(asyncio.gather(
battle_monitor.grab_new_battles(loop),
battle_monitor.process_battles(loop),
battle_reporting.report_battles(loop),
))
if __name__ == '__main__':
main()
| import asyncio
import logging
import os
from warreport import battle_monitor, battle_reporting
logger = logging.getLogger("warreport")
def main():
logger.info("Starting main loop.")
logger.debug("Debug logging enabled.")
loop = asyncio.get_event_loop()
gathered_future = asyncio.gather(
battle_monitor.grab_new_battles(loop),
battle_monitor.process_battles(loop),
battle_reporting.report_battles(loop),
loop=loop,
)
try:
loop.run_until_complete(gathered_future)
except KeyboardInterrupt:
logger.info("Caught KeyboardInterrupt: Ending main loop.")
gathered_future.cancel()
loop.run_forever()
gathered_future.exception()
finally:
loop.close()
logger.info("Ended successfully.")
# TODO: this is basically so I don't have to Ctrl+C twice to exit. I don't know what holds up the process, and it
# would definitely be a good idea to find out!
os._exit(0)
if __name__ == '__main__':
main()
| Make another try at graceful exiting. | Make another try at graceful exiting.
This still does use os._exit() after all coroutines have finished, but it's significantly less spaghetti code, and it makes it nicer to exit the program.
| Python | mit | daboross/screeps-warreport |
9c39105f2dcb296590e895aaf35de5d4c3105ddb | ephypype/commands/tests/test_cli.py | ephypype/commands/tests/test_cli.py | """Test neuropycon command line interface"""
# Authors: Dmitrii Altukhov <[email protected]>
#
# License: BSD (3-clause)
import os
import os.path as op
from ephypype.commands import neuropycon
from click.testing import CliRunner
def test_input_linear():
"""Test input node with Linear plugin (serial workflow execution)"""
runner = CliRunner()
wf_name = 'test_input_linear'
with runner.isolated_filesystem():
with open('temp.fif', 'w') as f:
f.write('temp')
result = runner.invoke(neuropycon.cli, ['-s', os.getcwd(),
'-w', wf_name,
'input', 'temp.fif'])
assert result.exit_code == 0
assert os.path.exists(op.join(os.getcwd(), wf_name))
def test_input_multiproc():
"""Test input node with MultiProc plugin (parallel workflow execution)"""
runner = CliRunner()
wf_name = 'test_input_multiproc'
with runner.isolated_filesystem():
with open('temp.fif', 'w') as f:
f.write('temp')
result = runner.invoke(neuropycon.cli, ['-s', os.getcwd(),
'-w', wf_name,
'-p', 'MultiProc',
'input', 'temp.fif'])
assert result.exit_code == 0
assert os.path.exists(op.join(os.getcwd(), wf_name))
| """Test neuropycon command line interface"""
# Authors: Dmitrii Altukhov <[email protected]>
#
# License: BSD (3-clause)
import matplotlib # noqa
matplotlib.use('Agg') # noqa; for testing don't use X server
import os
import os.path as op
from ephypype.commands import neuropycon
from click.testing import CliRunner
def test_input_linear():
"""Test input node with Linear plugin (serial workflow execution)"""
runner = CliRunner()
wf_name = 'test_input_linear'
with runner.isolated_filesystem():
with open('temp.fif', 'w') as f:
f.write('temp')
result = runner.invoke(neuropycon.cli, ['-s', os.getcwd(),
'-w', wf_name,
'input', 'temp.fif'])
assert result.exit_code == 0
assert os.path.exists(op.join(os.getcwd(), wf_name))
def test_input_multiproc():
"""Test input node with MultiProc plugin (parallel workflow execution)"""
runner = CliRunner()
wf_name = 'test_input_multiproc'
with runner.isolated_filesystem():
with open('temp.fif', 'w') as f:
f.write('temp')
result = runner.invoke(neuropycon.cli, ['-s', os.getcwd(),
'-w', wf_name,
'-p', 'MultiProc',
'input', 'temp.fif'])
assert result.exit_code == 0
assert os.path.exists(op.join(os.getcwd(), wf_name))
| FIX matplotlib backend problem in cli tests | FIX matplotlib backend problem in cli tests
| Python | bsd-3-clause | neuropycon/ephypype |
3204b2d5110a1a5cd16bad36ba5d5e916741fd2b | sensomatic/ui/persistence/models.py | sensomatic/ui/persistence/models.py | from peewee import *
db = SqliteDatabase('sensors.db')
class Sensor(Model):
name = CharField()
value = CharField()
timestamp = DateField()
class Meta:
database = db # This model uses the "people.db" database.
def get_last_record(sensor_name):
records = list(Sensor.select(Sensor.value).
where(Sensor.name == sensor_name).
order_by(Sensor.timestamp.desc()).
limit(1))
if records:
return records[0]
if __name__ == "__main__":
db.create_tables([Sensor])
| from peewee import *
db = SqliteDatabase('sensors.db')
class Sensor(Model):
name = CharField()
value = CharField()
timestamp = DateTimeField()
class Meta:
database = db # This model uses the "people.db" database.
def get_last_record(sensor_name):
records = list(Sensor.select(Sensor.value).
where(Sensor.name == sensor_name).
order_by(Sensor.timestamp.desc()).
limit(1))
if records:
return records[0]
if __name__ == "__main__":
db.create_tables([Sensor])
| Store datetime instead of only date | Store datetime instead of only date
| Python | mit | rrader/sens-o-matic,rrader/sens-o-matic,rrader/sens-o-matic |
92d25e86620fcdc415e94d5867cc22a95f88ca3a | mint/rest/db/awshandler.py | mint/rest/db/awshandler.py | #
# Copyright (c) 2009 rPath, Inc.
#
# All Rights Reserved
#
from mint import amiperms
class AWSHandler(object):
def __init__(self, cfg, db):
self.db = db
self.amiPerms = amiperms.AMIPermissionsManager(cfg, db)
def notify_UserProductRemoved(self, event, userId, projectId, userlevel = None):
self.amiPerms.addMemberToProject(userId, projectId)
def notify_UserProductAdded(self, event, userId, projectId, userlevel = None):
self.amiPerms.deleteMemberFromProject(userId, projectId)
def notify_UserProductChanged(self, event, userId, projectId, oldLevel,
newLevel):
self.amiPerms.setMemberLevel(userId, projectId, oldLevel, newLevel)
def notify_UserCancelled(self, userId):
# yuck.
awsFound, oldAwsAccountNumber = self.db.userData.getDataValue(
userId, 'awsAccountNumber')
self.amiPerms.setUserKey(userId, oldAwsAccountNumber, None)
def notify_ReleasePublished(self, releaseId):
self.amiPerms.publishRelease(releaseId)
def notify_ReleaseUnpublished(self, releaseId):
self.amiPerms.unpublishRelease(releaseId)
| #
# Copyright (c) 2009 rPath, Inc.
#
# All Rights Reserved
#
from mint import amiperms
class AWSHandler(object):
def __init__(self, cfg, db):
self.db = db
self.amiPerms = amiperms.AMIPermissionsManager(cfg, db)
def notify_UserProductRemoved(self, event, userId, projectId, userlevel = None):
self.amiPerms.deleteMemberFromProject(userId, projectId)
def notify_UserProductAdded(self, event, userId, projectId, userlevel = None):
self.amiPerms.addMemberToProject(userId, projectId)
def notify_UserProductChanged(self, event, userId, projectId, oldLevel,
newLevel):
self.amiPerms.setMemberLevel(userId, projectId, oldLevel, newLevel)
def notify_UserCancelled(self, userId):
# yuck.
awsFound, oldAwsAccountNumber = self.db.userData.getDataValue(
userId, 'awsAccountNumber')
self.amiPerms.setUserKey(userId, oldAwsAccountNumber, None)
def notify_ReleasePublished(self, releaseId):
self.amiPerms.publishRelease(releaseId)
def notify_ReleaseUnpublished(self, releaseId):
self.amiPerms.unpublishRelease(releaseId)
| Fix typo when setting up handler. | Fix typo when setting up handler.
| Python | apache-2.0 | sassoftware/mint,sassoftware/mint,sassoftware/mint,sassoftware/mint,sassoftware/mint |
09b2fe8b248e70300470fcf71f6df0741376c548 | misc/disassemble_linear.py | misc/disassemble_linear.py | import sys
import time
import bracoujl.processor.gb_z80 as proc
dis = proc.CPU_CONF['disassembler']()
def disassemble(lines):
res = ''
for line in lines:
op = proc.CPU_CONF['parse_line'](line)
if op is None:
continue
res += '{:04X}'.format(op['pc']) + ' - ' + dis.disassemble(op) + '\n'
res += '-' * 30
return res
try:
N = int(sys.argv[1])
except (ValueError, IndexError):
N = -1
uniq, lines, count = set(), [], 0
for line in sys.stdin:
if line == '--\n':
tlines = disassemble(lines)
if tlines not in uniq:
uniq.add(tlines)
print(tlines)
lines = []
if N == count:
sys.exit(0)
count += 1
lines.append(line[:-1])
| import argparse
import sys
import time
import bracoujl.processor.gb_z80 as proc
dis = proc.CPU_CONF['disassembler']()
def disassemble(lines, keep_logs=False):
res = []
for line in lines:
op, gline = proc.CPU_CONF['parse_line'](line), ''
if keep_logs:
gline += line + (' | DIS: ' if op is not None else '')
else:
gline += '{:04X}'.format(op['pc']) + ' - '
if op is not None:
gline += dis.disassemble(op)
res.append(gline)
res.append('-' * 20)
return '\n'.join(res)
uniq = set()
def display_lines(lines, **kwds):
tlines = disassemble(lines, **kwds)
if tlines not in uniq:
uniq.add(tlines)
print(tlines)
return []
if __name__ == '__main__':
parser = argparse.ArgumentParser(description='Little disassembly helper.')
parser.add_argument('-N', action='store', default=-1,
help='number of uniq blocks displayed')
parser.add_argument('-k', '--keep-logs', action='store_true', default=False,
help='keep log lines')
args = parser.parse_args(sys.argv[1:])
lines, count = [], 0
for line in sys.stdin:
if line == '--\n':
lines = display_lines(lines, keep_logs=args.keep_logs)
if args.N == count:
sys.exit(0)
count += 1
lines.append(line[:-1])
if lines:
display_lines(lines, keep_logs=args.keep_logs)
| Fix and enhance disassemble miscellaneous script. | Fix and enhance disassemble miscellaneous script.
| Python | bsd-3-clause | fmichea/bracoujl |
e0063c0d5604372c1a07a179f5206a0a27570817 | package_reviewer/check/repo/check_semver_tags.py | package_reviewer/check/repo/check_semver_tags.py | import re
from . import RepoChecker
class CheckSemverTags(RepoChecker):
def check(self):
if not self.semver_tags:
msg = "No semantic version tags found. See http://semver.org."
for tag in self.tags:
if re.search(r"(v|^)\d+\.\d+$", tag.name):
msg += " Semantic versions consist of exactly three numeric parts."
break
self.fail(msg)
| import re
from . import RepoChecker
class CheckSemverTags(RepoChecker):
def check(self):
if not self.semver_tags:
msg = "No semantic version tags found"
for tag in self.tags:
if re.search(r"(v|^)\d+\.\d+$", tag.name):
msg += " (semantic versions consist of exactly three numeric parts)"
break
self.fail(msg)
| Change message of semver tag check | Change message of semver tag check
| Python | mit | packagecontrol/st_package_reviewer,packagecontrol/package_reviewer |
d3163d8a7695da9687f82d9d40c6767322998fc2 | python/ql/test/experimental/dataflow/tainttracking/defaultAdditionalTaintStep-py3/test_collections.py | python/ql/test/experimental/dataflow/tainttracking/defaultAdditionalTaintStep-py3/test_collections.py | # Add taintlib to PATH so it can be imported during runtime without any hassle
import sys; import os; sys.path.append(os.path.dirname(os.path.dirname((__file__))))
from taintlib import *
# This has no runtime impact, but allows autocomplete to work
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from ..taintlib import *
# Actual tests
def test_access():
tainted_list = TAINTED_LIST
ensure_tainted(
tainted_list.copy(), # $ tainted
)
def list_clear():
tainted_string = TAINTED_STRING
tainted_list = [tainted_string]
ensure_tainted(tainted_list) # $ tainted
tainted_list.clear()
ensure_not_tainted(tainted_list) # $ SPURIOUS: tainted
# Make tests runable
test_access()
list_clear()
| # Add taintlib to PATH so it can be imported during runtime without any hassle
import sys; import os; sys.path.append(os.path.dirname(os.path.dirname((__file__))))
from taintlib import *
# This has no runtime impact, but allows autocomplete to work
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from ..taintlib import *
# Actual tests
def test_access():
tainted_list = TAINTED_LIST
ensure_tainted(
tainted_list.copy(), # $ tainted
)
for ((x, y, *z), a, b) in tainted_list:
ensure_tainted(
x, # $ tainted
y, # $ tainted
z, # $ tainted
a, # $ tainted
b, # $ tainted
)
def list_clear():
tainted_string = TAINTED_STRING
tainted_list = [tainted_string]
ensure_tainted(tainted_list) # $ tainted
tainted_list.clear()
ensure_not_tainted(tainted_list) # $ SPURIOUS: tainted
# Make tests runable
test_access()
list_clear()
| Add iterable-unpacking in for test | Python: Add iterable-unpacking in for test
| Python | mit | github/codeql,github/codeql,github/codeql,github/codeql,github/codeql,github/codeql,github/codeql,github/codeql,github/codeql,github/codeql,github/codeql,github/codeql,github/codeql,github/codeql,github/codeql |
679abfdd2b6a3c4d18170d93bfd42d73c47ff9c5 | phasm/typing.py | phasm/typing.py | """
Several type aliases used througout PHASM
-----------------------------------------
This is a separate module to prevent circular imports.
"""
from typing import Mapping, Set, Callable, Union, Tuple, Iterable
# Pairwise local alignments
OrientedDNASegment = 'phasm.alignments.OrientedDNASegment'
OrientedRead = 'phasm.alignments.OrientedRead'
LocalAlignment = 'phasm.alignments.LocalAlignment'
AlignmentsT = Mapping[OrientedRead, Set[LocalAlignment]]
# Assembly Graphs
AssemblyGraph = 'phasm.assembly_graph.AssemblyGraph'
Node = OrientedDNASegment
Edge = Tuple[Node, Node]
Path = Iterable[Edge]
Bubble = Tuple[Node, Node]
# Phasing algorithm parameters
PruneParam = Union[float, Callable[[float], float]]
| """
Several type aliases used througout PHASM
-----------------------------------------
This is a separate module to prevent circular imports.
"""
from typing import Mapping, Set, Callable, Union, Tuple, Iterable
# Pairwise local alignments
OrientedDNASegment = 'phasm.alignments.OrientedDNASegment'
OrientedRead = 'phasm.alignments.OrientedRead'
LocalAlignment = 'phasm.alignments.LocalAlignment'
AlignmentsT = Mapping[OrientedRead, Set[LocalAlignment]]
# Assembly Graphs
AssemblyGraph = 'phasm.assembly_graph.AssemblyGraph'
Node = Union[OrientedDNASegment, str]
Edge = Tuple[Node, Node]
Path = Iterable[Edge]
Bubble = Tuple[Node, Node]
# Phasing algorithm parameters
PruneParam = Union[float, Callable[[float], float]]
| Change Node type a bit | Change Node type a bit
In a reconstructed assembly graph sometimes the nodes can be str
| Python | mit | AbeelLab/phasm,AbeelLab/phasm |
fea07e0fe53049963a744b52c38a9abdfeb1c09e | commands.py | commands.py | from os import path
import shutil
import sublime
import sublime_plugin
SUBLIME_ROOT = path.normpath(path.join(sublime.packages_path(), '..'))
COMMANDS_FILEPATH = path.join('Packages', 'User', 'Commands.sublime-commands')
COMMANDS_FULL_FILEPATH = path.join(SUBLIME_ROOT, COMMANDS_FILEPATH)
COMMANDS_SOURCE_FULL_FILEPATH = path.abspath('default-prompt.json')
class CommandsOpenCommand(sublime_plugin.WindowCommand):
def run(self, **kwargs):
"""Open `.sublime-commands` file for custom definitions"""
# If no file is provided, default to `COMMANDS_FULL_FILEPATH`
dest_filepath = kwargs.get('file', COMMANDS_FULL_FILEPATH)
# If the file doesn't exist, provide a prompt
if not path.exists(dest_filepath):
shutil.copy(COMMANDS_SOURCE_FULL_FILEPATH, dest_filepath)
# Open the User commands file
view = self.window.open_file(dest_filepath)
# If the syntax is plain text, move to JSON
if view.settings().get('syntax') == path.join('Packages', 'Text', 'Plain text.tmLanguage'):
view.set_syntax_file(path.join('Packages', 'JavaScript', 'JSON.tmLanguage'))
| from os import path
import shutil
import sublime
import sublime_plugin
SUBLIME_ROOT = path.normpath(path.join(sublime.packages_path(), '..'))
COMMANDS_FILEPATH = path.join('Packages', 'User', 'Commands.sublime-commands')
COMMANDS_FULL_FILEPATH = path.join(SUBLIME_ROOT, COMMANDS_FILEPATH)
COMMANDS_SOURCE_FULL_FILEPATH = path.abspath('default-prompt.json')
class CommandsOpenCommand(sublime_plugin.WindowCommand):
def run(self):
"""Open `Packages/User/Commands.sublime-commands` for custom definitions"""
# If the User commands doesn't exist, provide a prompt
if not path.exists(COMMANDS_FULL_FILEPATH):
shutil.copy(COMMANDS_SOURCE_FULL_FILEPATH, COMMANDS_FULL_FILEPATH)
# Open the User commands file
view = self.window.open_file(COMMANDS_FULL_FILEPATH)
# If the syntax is plain text, move to JSON
if view.settings().get('syntax') == path.join('Packages', 'Text', 'Plain text.tmLanguage'):
view.set_syntax_file(path.join('Packages', 'JavaScript', 'JSON.tmLanguage'))
| Revert "Started exploring using argument but realizing this is a rabbit hole" | Revert "Started exploring using argument but realizing this is a rabbit hole"
This reverts commit b899d5613c0f4425aa4cc69bac9561b503ba83d4.
| Python | unlicense | twolfson/sublime-edit-command-palette,twolfson/sublime-edit-command-palette,twolfson/sublime-edit-command-palette |
b21c5a1b0f8d176cdd59c8131a316f142540d9ec | materials.py | materials.py | import color
def parse(mat_node):
materials = []
for node in mat_node:
materials.append(Material(node))
class Material:
''' it’s a material
'''
def __init__(self, node):
for c in node:
if c.tag == 'ambient':
self.ambient_color = color.parse(c[0])
self.ambient_color *= float(c.attrib['factor'].replace(',', '.'))
elif c.tag == 'diffuse':
self.diffuse_color = color.parse(c[0])
self.diffuse_color *= float(c.attrib['factor'].replace(',', '.'))
elif c.tag == 'specular':
self.specular_color = color.parse(c[0])
self.specular_color *= float(c.attrib['factor'].replace(',', '.'))
elif c.tag == 'reflection':
self.reflection_color = color.parse(c[0])
self.reflection_color *= float(c.attrib['factor'].replace(',', '.'))
| import color
def parse(mat_node):
materials = []
for node in mat_node:
materials.append(Material(node))
class Material:
''' it’s a material
'''
def __init__(self, node):
for c in node:
if c.tag == 'ambient':
self.ambient_color = color.parse(c[0])
self.ambient_color *= float(c.attrib['factor'])
elif c.tag == 'diffuse':
self.diffuse_color = color.parse(c[0])
self.diffuse_color *= float(c.attrib['factor'])
elif c.tag == 'specular':
self.specular_color = color.parse(c[0])
self.specular_color *= float(c.attrib['factor'])
elif c.tag == 'reflection':
self.reflection_color = color.parse(c[0])
self.reflection_color *= float(c.attrib['factor'])
| Remove replacement of commas by points | Remove replacement of commas by points
| Python | mit | cocreature/pytracer |
2fe72f41b1b62cf770869b8d3ccefeef1096ea11 | conftest.py | conftest.py | # -*- coding: UTF-8 -*-
"""
Configure pytest environment.
Add project-specific information.
.. seealso::
* https://github.com/pytest-dev/pytest-html
"""
import behave
import pytest
@pytest.fixture(autouse=True)
def _annotate_environment(request):
"""Add project-specific information to test-run environment:
* behave.version
NOTE: autouse: Fixture is automatically used when test-module is imported.
"""
# -- USEFULL FOR: pytest --html=report.html ...
behave_version = behave.__version__
request.config._environment.append(("behave", behave_version))
| # -*- coding: UTF-8 -*-
"""
Configure pytest environment.
Add project-specific information.
.. seealso::
* https://github.com/pytest-dev/pytest-html
"""
import behave
import pytest
@pytest.fixture(autouse=True)
def _annotate_environment(request):
"""Add project-specific information to test-run environment:
* behave.version
NOTE: autouse: Fixture is automatically used when test-module is imported.
"""
# -- USEFULL FOR: pytest --html=report.html ...
environment = getattr(request.config, "_environment", None)
if environment:
# -- PROVIDED-BY: pytest-html
behave_version = behave.__version__
environment.append(("behave", behave_version))
| FIX when pytest-html is not installed. | FIX when pytest-html is not installed.
| Python | bsd-2-clause | Abdoctor/behave,Abdoctor/behave,jenisys/behave,jenisys/behave |
6df2a6e82a04c6cb19a789c55f758d0958a9b690 | nipype/interfaces/setup.py | nipype/interfaces/setup.py | def configuration(parent_package='',top_path=None):
from numpy.distutils.misc_util import Configuration
config = Configuration('interfaces', parent_package, top_path)
config.add_data_dir('tests')
config.add_data_dir('script_templates')
return config
if __name__ == '__main__':
from numpy.distutils.core import setup
setup(**configuration(top_path='').todict())
| def configuration(parent_package='',top_path=None):
from numpy.distutils.misc_util import Configuration
config = Configuration('interfaces', parent_package, top_path)
config.add_subpackage('fsl')
config.add_data_dir('tests')
config.add_data_dir('script_templates')
return config
if __name__ == '__main__':
from numpy.distutils.core import setup
setup(**configuration(top_path='').todict())
| Add fsl subpackage on install. | Add fsl subpackage on install.
git-svn-id: 24f545668198cdd163a527378499f2123e59bf9f@1050 ead46cd0-7350-4e37-8683-fc4c6f79bf00
| Python | bsd-3-clause | glatard/nipype,rameshvs/nipype,arokem/nipype,wanderine/nipype,wanderine/nipype,FredLoney/nipype,dmordom/nipype,arokem/nipype,Leoniela/nipype,blakedewey/nipype,wanderine/nipype,dmordom/nipype,FCP-INDI/nipype,FredLoney/nipype,gerddie/nipype,FCP-INDI/nipype,christianbrodbeck/nipype,iglpdc/nipype,mick-d/nipype,satra/NiPypeold,arokem/nipype,pearsonlab/nipype,wanderine/nipype,iglpdc/nipype,arokem/nipype,grlee77/nipype,FCP-INDI/nipype,mick-d/nipype,mick-d/nipype_source,pearsonlab/nipype,JohnGriffiths/nipype,dmordom/nipype,gerddie/nipype,dgellis90/nipype,iglpdc/nipype,grlee77/nipype,blakedewey/nipype,sgiavasis/nipype,sgiavasis/nipype,christianbrodbeck/nipype,iglpdc/nipype,carlohamalainen/nipype,sgiavasis/nipype,glatard/nipype,grlee77/nipype,carolFrohlich/nipype,dgellis90/nipype,Leoniela/nipype,mick-d/nipype_source,glatard/nipype,carolFrohlich/nipype,blakedewey/nipype,sgiavasis/nipype,FredLoney/nipype,FCP-INDI/nipype,fprados/nipype,blakedewey/nipype,carolFrohlich/nipype,dgellis90/nipype,satra/NiPypeold,rameshvs/nipype,dgellis90/nipype,mick-d/nipype,fprados/nipype,pearsonlab/nipype,JohnGriffiths/nipype,JohnGriffiths/nipype,carlohamalainen/nipype,gerddie/nipype,mick-d/nipype_source,pearsonlab/nipype,rameshvs/nipype,Leoniela/nipype,carolFrohlich/nipype,grlee77/nipype,glatard/nipype,gerddie/nipype,JohnGriffiths/nipype,mick-d/nipype,carlohamalainen/nipype,rameshvs/nipype,fprados/nipype |
1f6fb7bb0e20cafbe4392bf8a0cafa3e9fa2fbc1 | main.py | main.py | #!/usr/bin/python
from pytun import TunTapDevice
from binascii import hexlify
if __name__ == '__main__':
tun = TunTapDevice(name='ipsec-tun')
tun.up()
tun.persist(True)
while True:
try:
buf = tun.read(tun.mtu)
print hexlify(buf[4:])
IPpayload = buf[4:]
# TODO encrypt buf
# TODO send to wlan0
# TODO enable routing
except KeyboardInterrupt:
tun.close()
| #!/usr/bin/env python
from pytun import TunTapDevice
from binascii import hexlify
if __name__ == '__main__':
tun = TunTapDevice(name='ipsec-tun')
tun.up()
tun.persist(True)
while True:
try:
buf = tun.read(tun.mtu)
print hexlify(buf[4:])
IPpayload = buf[4:]
# TODO encrypt buf
# TODO send to wlan0
# TODO enable routing
except KeyboardInterrupt:
tun.close()
| Change shebang to use python from environment. Fix Indentation. | Change shebang to use python from environment. Fix Indentation.
| Python | mit | adrian-nicolau/ipsec-poc,adrian-nicolau/ipsec-poc |
6267fa5d9a3ff2573dc33a23d3456942976b0b7e | cyder/base/models.py | cyder/base/models.py | from django.db import models
from django.utils.safestring import mark_safe
from cyder.base.utils import classproperty
class BaseModel(models.Model):
"""
Base class for models to abstract some common features.
* Adds automatic created and modified fields to the model.
"""
created = models.DateTimeField(auto_now_add=True, null=True)
modified = models.DateTimeField(auto_now=True, null=True)
class Meta:
abstract = True
get_latest_by = 'created'
@classproperty
@classmethod
def pretty_type(cls):
return cls.__name__.lower()
@property
def pretty_name(self):
return unicode(self)
def unique_error_message(self, model_class, unique_check):
error = super(BaseModel, self).unique_error_message(
model_class, unique_check)
kwargs = {}
for field in unique_check:
kwargs[field] = getattr(self, field)
obj = model_class.objects.filter(**kwargs)
if obj and hasattr(obj.get(), 'get_detail_url'):
error = error[:-1] + ' at <a href={0}>{1}.</a>'.format(
obj.get().get_detail_url(), obj.get())
error = mark_safe(error)
return error
class ExpirableMixin(models.Model):
expire = models.DateTimeField(null=True, blank=True)
class Meta:
abstract = True
| from django.db import models
from django.utils.safestring import mark_safe
from cyder.base.utils import classproperty
class BaseModel(models.Model):
"""
Base class for models to abstract some common features.
* Adds automatic created and modified fields to the model.
"""
created = models.DateTimeField(auto_now_add=True, null=True)
modified = models.DateTimeField(auto_now=True, null=True)
class Meta:
abstract = True
get_latest_by = 'created'
@classproperty
@classmethod
def pretty_type(cls):
return cls.__name__.lower()
@property
def pretty_name(self):
return unicode(self)
def unique_error_message(self, model_class, unique_check):
error = super(BaseModel, self).unique_error_message(
model_class, unique_check)
kwargs = {}
for field in unique_check:
kwargs[field] = getattr(self, field)
obj = model_class.objects.filter(**kwargs)
if obj and hasattr(obj.get(), 'get_detail_url'):
error = error[:-1] + ' at <a href={0}>{1}.</a>'.format(
obj.get().get_detail_url(), obj.get())
error = mark_safe(error)
return error
class ExpirableMixin(models.Model):
expire = models.DateTimeField(null=True, blank=True,
help_text='Format: MM/DD/YYYY')
class Meta:
abstract = True
| Add help_text to interface 'expire' field | Add help_text to interface 'expire' field
| Python | bsd-3-clause | OSU-Net/cyder,zeeman/cyder,drkitty/cyder,zeeman/cyder,OSU-Net/cyder,murrown/cyder,OSU-Net/cyder,murrown/cyder,murrown/cyder,drkitty/cyder,drkitty/cyder,OSU-Net/cyder,akeym/cyder,murrown/cyder,akeym/cyder,akeym/cyder,drkitty/cyder,zeeman/cyder,zeeman/cyder,akeym/cyder |
2150f99461e4790477ad90483a7f716f09679ef1 | p025.py | p025.py | #!/usr/bin/env python3
"""Solves problem xxx from the Project Euler website"""
from common.fibonacci import fibonacci_numbers_until_n_digits
def solve():
"""Solve the problem and return the result"""
fibonacci_numbers = fibonacci_numbers_until_n_digits(1000)
result = len(fibonacci_numbers)
return result
if __name__ == '__main__':
print(solve())
| #!/usr/bin/env python3
"""Solves problem 025 from the Project Euler website"""
from common.fibonacci import fibonacci_numbers_until_n_digits
def solve():
"""Solve the problem and return the result"""
fibonacci_numbers = fibonacci_numbers_until_n_digits(1000)
result = len(fibonacci_numbers)
return result
if __name__ == '__main__':
print(solve())
| Fix comment in previous commit. | Fix comment in previous commit.
| Python | mit | janhenke/project-euler |
f29a6b205a872d7df63e8c45b5829959c98de227 | comics/comics/pcweenies.py | comics/comics/pcweenies.py | from comics.aggregator.crawler import CrawlerBase, CrawlerResult
from comics.meta.base import MetaBase
class Meta(MetaBase):
name = 'The PC Weenies'
language = 'en'
url = 'http://www.pcweenies.com/'
start_date = '1998-10-21'
rights = 'Krishna M. Sadasivam'
class Crawler(CrawlerBase):
history_capable_days = 10
schedule = 'Mo,We,Fr'
time_zone = -8
def crawl(self, pub_date):
feed = self.parse_feed('http://www.pcweenies.com/feed/')
for entry in feed.for_date(pub_date):
if 'Comic' in entry.tags:
title = entry.title
url = entry.content0.src(u'img')
return CrawlerResult(url, title)
| from comics.aggregator.crawler import CrawlerBase, CrawlerResult
from comics.meta.base import MetaBase
class Meta(MetaBase):
name = 'The PC Weenies'
language = 'en'
url = 'http://www.pcweenies.com/'
start_date = '1998-10-21'
rights = 'Krishna M. Sadasivam'
class Crawler(CrawlerBase):
history_capable_days = 10
schedule = 'Mo,We,Fr'
time_zone = -8
def crawl(self, pub_date):
feed = self.parse_feed('http://www.pcweenies.com/feed/')
for entry in feed.for_date(pub_date):
if 'Comic' in entry.tags:
title = entry.title
url = entry.content0.src(u'img[src*="/comics/"]')
return CrawlerResult(url, title)
| Update CSS selector which matched two img elements | Update CSS selector which matched two img elements
| Python | agpl-3.0 | klette/comics,jodal/comics,jodal/comics,datagutten/comics,jodal/comics,datagutten/comics,jodal/comics,klette/comics,klette/comics,datagutten/comics,datagutten/comics |
5f0f1da10ebc01d95bb8659f5dc7782e57365b53 | .conda/to_cargoport.py | .conda/to_cargoport.py | #!/usr/bin/env python
import sys
import yaml
def extDetect(url):
if url.endswith('.tar.gz'):
return '.tar.gz'
elif url.endswith('.tgz'):
return '.tar.gz'
elif url.endswith('.tar.bz2'):
return '.tar.bz2'
elif url.endswith('.tar.xz'):
return '.tar.xz'
else:
return url[url.rindex('.'):]
for element in yaml.load(sys.stdin):
{'url': 'https://github.com/arq5x/lumpy-sv/66c83c8.tar.gz', 'version': '0.2.12', 'arch': 'linux-64', 'name': 'lumpy-sv'}
# Id Version Platform Architecture Upstream Url Extension sha256sum Use upstream
platform = element['arch']
arch = 'x64'
if platform == 'src':
arch = 'all'
elif platform == 'osx-':
platform = 'darwin'
elif platform == 'linux-64':
platform = 'linux'
print '\t'.join([
element['name'],
element['version'],
platform,
arch,
element['url'],
extDetect(element['url']),
"",
"True"
])
| #!/usr/bin/env python
import sys
import yaml
def extDetect(url):
if url.endswith('.tar.gz'):
return '.tar.gz'
elif url.endswith('.tgz'):
return '.tar.gz'
elif url.endswith('.tar.bz2'):
return '.tar.bz2'
elif url.endswith('.tar.xz'):
return '.tar.xz'
else:
guess = url[url.rindex('.'):]
# If there's a slash, that's DEFINITELY not an extension. Return empty
# and hope downstream handles that OK.
if '/' in guess:
return ''
return guess
for element in yaml.load(sys.stdin):
{'url': 'https://github.com/arq5x/lumpy-sv/66c83c8.tar.gz', 'version': '0.2.12', 'arch': 'linux-64', 'name': 'lumpy-sv'}
# Id Version Platform Architecture Upstream Url Extension sha256sum Use upstream
platform = element['arch']
arch = 'x64'
if platform == 'src':
arch = 'all'
elif platform == 'osx-':
platform = 'darwin'
elif platform == 'linux-64':
platform = 'linux'
print '\t'.join([
element['name'],
element['version'],
platform,
arch,
element['url'],
extDetect(element['url']),
"",
"True"
])
| Fix download issue for a few packages | Fix download issue for a few packages
| Python | mit | erasche/community-package-cache,erasche/community-package-cache,gregvonkuster/cargo-port,gregvonkuster/cargo-port,galaxyproject/cargo-port,galaxyproject/cargo-port,erasche/community-package-cache,gregvonkuster/cargo-port |
54f53815653f807c17c33e9d3262d9d3a31abfcf | scripts/fill_events.py | scripts/fill_events.py | #!/usr/bin/env python
import sys
import os
sys.path.append(os.path.join(os.path.dirname('__file__'), '..', 'src'))
from random import randint
from datetime import datetime, timedelta
from logsandra.model.client import CassandraClient
client = CassandraClient('test', 'localhost', 9160, 3)
today = datetime.now()
keywords = ['foo', 'bar', 'baz']
for i in range(1000):
d = today + timedelta(randint(-7, -1), randint(-3600*24, 3600*24))
client.add_log(d, 'test entry', 'here', [keywords[i % 3]])
| #!/usr/bin/env python
import sys
import os
sys.path.append(os.path.join(os.path.dirname('__file__'), '..', 'src'))
from random import randint
from datetime import datetime, timedelta
from logsandra.model.client import CassandraClient
client = CassandraClient('test', 'localhost', 9160, 3)
keywords = ['foo', 'bar', 'baz']
print "Loading sample data for the following keywords:", ', '.join(keywords)
today = datetime.now()
for i in range(1000):
d = today + timedelta(randint(-7, -1), randint(-3600*24, 3600*24))
client.add_log(d, 'test entry', 'here', [keywords[i % len(keywords)]])
| Print info about keywords when loading sample data | Print info about keywords when loading sample data
| Python | mit | thobbs/logsandra |
6ad647899d044cb46be6172cbea9c93a369ddc78 | pymanopt/solvers/theano_functions/comp_diff.py | pymanopt/solvers/theano_functions/comp_diff.py | # Module containing functions to compile and differentiate Theano graphs.
import theano.tensor as T
import theano
# Compile objective function defined in Theano.
def compile(objective, argument):
return theano.function([argument], objective)
# Compute the gradient of 'objective' with respect to 'argument' and return
# compiled function.
def gradient(objective, argument):
g = T.grad(objective, argument)
return theano.function([argument], g) | # Module containing functions to compile and differentiate Theano graphs.
import theano.tensor as T
import theano
# Compile objective function defined in Theano.
def compile(objective, argument):
return theano.function([argument], objective)
# Compute the gradient of 'objective' with respect to 'argument' and return
# compiled function.
def gradient(objective, argument):
g = T.grad(objective, argument)
return compile(g, argument)
| Use `compile` function for `gradient` function | Use `compile` function for `gradient` function
Signed-off-by: Niklas Koep <[email protected]>
| Python | bsd-3-clause | j-towns/pymanopt,nkoep/pymanopt,pymanopt/pymanopt,tingelst/pymanopt,nkoep/pymanopt,pymanopt/pymanopt,nkoep/pymanopt |
48e4203bc87fda407d0e5f804c854b53f7bf54fc | lemon/publications/managers.py | lemon/publications/managers.py | from django.db import models
from lemon.publications.querysets import PublicationQuerySet
class PublicationManager(models.Manager):
def expired(self):
return self.get_query_set().expired()
def future(self):
return self.get_query_set().future()
def enabled(self):
return self.get_query_set().enabled()
def disabled(self):
return self.get_query_set().disabled()
def unpublished(self):
return self.get_query_set().unpublished()
def published(self):
return self.get_query_set().published()
def get_query_set(self):
return PublicationQuerySet(self.model)
| from django.db import models
from lemon.publications.querysets import PublicationQuerySet
class PublicationManager(models.Manager):
def expired(self):
return self.get_query_set().expired()
def future(self):
return self.get_query_set().future()
def enabled(self):
return self.get_query_set().enabled()
def disabled(self):
return self.get_query_set().disabled()
def unpublished(self):
return self.get_query_set().unpublished()
def published(self):
return self.get_query_set().published()
def get_query_set(self):
return PublicationQuerySet(self.model, using=self._db)
| Fix handling of the _db attribute on the PublicationManager in get_query_set | Fix handling of the _db attribute on the PublicationManager in get_query_set
| Python | bsd-3-clause | trilan/lemon,trilan/lemon,trilan/lemon |
3c4565dcf6222af0e3b7cabf5c52f9ab18488be2 | tests/test_main.py | tests/test_main.py | from cookiecutter.main import is_repo_url, expand_abbreviations
def test_is_repo_url():
"""Verify is_repo_url works."""
assert is_repo_url('gitolite@server:team/repo') is True
assert is_repo_url('[email protected]:audreyr/cookiecutter.git') is True
assert is_repo_url('https://github.com/audreyr/cookiecutter.git') is True
assert is_repo_url('https://bitbucket.org/pokoli/cookiecutter.hg') is True
assert is_repo_url('/audreyr/cookiecutter.git') is False
assert is_repo_url('/home/audreyr/cookiecutter') is False
appveyor_temp_dir = (
'c:\\users\\appveyor\\appdata\\local\\temp\\1\\pytest-0\\'
'test_default_output_dir0\\template'
)
assert is_repo_url(appveyor_temp_dir) is False
def test_expand_abbreviations():
template = 'gh:audreyr/cookiecutter-pypackage'
# This is not a valid repo url just yet!
# First `main.expand_abbreviations` needs to translate it
assert is_repo_url(template) is False
expanded_template = expand_abbreviations(template, {})
assert is_repo_url(expanded_template) is True
| # -*- coding: utf-8 -*-
import pytest
from cookiecutter.main import is_repo_url, expand_abbreviations
@pytest.fixture(params=[
'gitolite@server:team/repo',
'[email protected]:audreyr/cookiecutter.git',
'https://github.com/audreyr/cookiecutter.git',
'https://bitbucket.org/pokoli/cookiecutter.hg',
])
def remote_repo_url(request):
return request.param
def test_is_repo_url_for_remote_urls(remote_repo_url):
"""Verify is_repo_url works."""
assert is_repo_url(remote_repo_url) is True
@pytest.fixture(params=[
'/audreyr/cookiecutter.git',
'/home/audreyr/cookiecutter',
(
'c:\\users\\appveyor\\appdata\\local\\temp\\1\\pytest-0\\'
'test_default_output_dir0\\template'
),
])
def local_repo_url(request):
return request.param
def test_is_repo_url_for_local_urls(local_repo_url):
"""Verify is_repo_url works."""
assert is_repo_url(local_repo_url) is False
def test_expand_abbreviations():
template = 'gh:audreyr/cookiecutter-pypackage'
# This is not a valid repo url just yet!
# First `main.expand_abbreviations` needs to translate it
assert is_repo_url(template) is False
expanded_template = expand_abbreviations(template, {})
assert is_repo_url(expanded_template) is True
| Refactor tests for is_repo_url to be parametrized | Refactor tests for is_repo_url to be parametrized
| Python | bsd-3-clause | luzfcb/cookiecutter,terryjbates/cookiecutter,michaeljoseph/cookiecutter,willingc/cookiecutter,pjbull/cookiecutter,stevepiercy/cookiecutter,hackebrot/cookiecutter,dajose/cookiecutter,Springerle/cookiecutter,dajose/cookiecutter,stevepiercy/cookiecutter,terryjbates/cookiecutter,audreyr/cookiecutter,pjbull/cookiecutter,audreyr/cookiecutter,luzfcb/cookiecutter,hackebrot/cookiecutter,willingc/cookiecutter,Springerle/cookiecutter,michaeljoseph/cookiecutter |
d312815697a3457ee0b3d12da9d07c0cab7a5622 | media.py | media.py | # media.py
class Movie(object):
def __init__(self,
title,
storyline,
poster_image_url,
trailer_youtube_url,
lead_actors,
release_date,
mpaa_rating,
language,
runtime,
production_company,
trivia
):
self.title = title
self.storyline = storyline
self.poster_image_url = poster_image_url
self.trailer_youtube_url = trailer_youtube_url
self.lead_actors = lead_actors
self.release_date = release_date
self.mpaa_rating = mpaa_rating
self.language = language
self.runtime = runtime
self.production_company = production_company
self.trivia = trivia
| # media.py
class Movie(object):
def __init__(self,
title,
storyline,
poster_image_url,
trailer_youtube_url,
lead_actors,
release_date,
mpaa_rating,
language,
runtime,
production_companies,
trivia
):
self.title = title
self.storyline = storyline
self.poster_image_url = poster_image_url
self.trailer_youtube_url = trailer_youtube_url
self.lead_actors = lead_actors
self.release_date = release_date
self.mpaa_rating = mpaa_rating
self.language = language
self.runtime = runtime
self.production_companies = production_companies
self.trivia = trivia
| Change Movie parameter from production_company to production_companies | Change Movie parameter from production_company to production_companies
| Python | mit | vishallama/udacity-fullstack-movie-trailer,vishallama/udacity-fullstack-movie-trailer |
4b6bb7b7d258a9f130b7d10f390f44dec855cc19 | admin/src/gui/NewScoville.py | admin/src/gui/NewScoville.py | #!/usr/bin/python
#-*- coding: utf-8 -*-
###########################################################
# Copyright 2011 Daniel 'grindhold' Brendle and Team
#
# This file is part of Scoville.
#
# Scoville is free software: you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation, either
# version 3 of the License, or (at your option) any later
# version.
#
# Scoville is distributed in the hope that it will be
# useful, but WITHOUT ANY WARRANTY; without even the implied
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
# PURPOSE. See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public
# License along with Scoville.
# If not, see http://www.gnu.org/licenses/.
###########################################################
import pygtk
pygtk.require("2.0")
import gtk
builder = gtk.Builder()
builder.add_from_file(os.path[0]+"/src/gui/NewScoville.ui")
class NewScovilleWindow(object):
def __init__(self):
pass | #!/usr/bin/python
#-*- coding: utf-8 -*-
###########################################################
# Copyright 2011 Daniel 'grindhold' Brendle and Team
#
# This file is part of Scoville.
#
# Scoville is free software: you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation, either
# version 3 of the License, or (at your option) any later
# version.
#
# Scoville is distributed in the hope that it will be
# useful, but WITHOUT ANY WARRANTY; without even the implied
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
# PURPOSE. See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public
# License along with Scoville.
# If not, see http://www.gnu.org/licenses/.
###########################################################
import pygtk
pygtk.require("2.0")
import gtk
builder = gtk.Builder()
builder.add_from_file(os.path[0]+"/src/gui/NewScoville.ui")
class NewScovilleWindow(object):
pass | Revert "added constructor (testcommit for new git interface)" | Revert "added constructor (testcommit for new git interface)"
This reverts commit d5c0252b75e97103d61c3203e2a8d04a061c8a2f.
| Python | agpl-3.0 | skarphed/skarphed,skarphed/skarphed |
f5c8c9909a8b7288503f1ed3dcd87c5e59d3817c | settings.py | settings.py | import os
class Config(object):
"""
The shared configuration settings for the flask app.
"""
PROJECT_ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__)))
CSRF_ENABLED = True
CSRF_SESSION_KEY = "supersecretpassword"
SECRET_KEY = 'supersecretpassword'
class ProdConfig(Config):
"""
Setup the production configuration for the flask app.
Args:
Config (object): Inherit the default shared configuration settings.
"""
ENV = 'prod'
DEBUG = False
heroku = os.environ.get('DATABASE_URL')
if heroku:
SQLALCHEMY_DATABASE_URI = heroku
else:
SQLALCHEMY_DATABASE_URI = 'postgresql://localhost/example'
class DevConfig(Config):
"""
Setup the development configuration for the flask app.
Args:
Config (object): Inherit the default shared configuration settings.
"""
ENV = 'dev'
DEBUG = True
DB_PATH = os.path.join(Config.PROJECT_ROOT, 'dev.db')
SQLALCHEMY_DATABASE_URI = 'sqlite:///{0}'.format(DB_PATH)
| import os
class Config(object):
"""
The shared configuration settings for the flask app.
"""
PROJECT_ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__)))
CSRF_ENABLED = True
CSRF_SESSION_KEY = "supersecretpassword"
SECRET_KEY = 'supersecretpassword'
class ProdConfig(Config):
"""
Setup the production configuration for the flask app.
Args:
Config (object): Inherit the default shared configuration settings.
"""
ENV = 'prod'
DEBUG = False
SQLALCHEMY_DATABASE_URI = os.environ.get('DATABASE_URL',
'postgresql://localhost/example')
class DevConfig(Config):
"""
Setup the development configuration for the flask app.
Args:
Config (object): Inherit the default shared configuration settings.
"""
ENV = 'dev'
DEBUG = True
DB_PATH = os.path.join(Config.PROJECT_ROOT, 'dev.db')
SQLALCHEMY_DATABASE_URI = 'sqlite:///{0}'.format(DB_PATH)
| Use environment db url, otherwise a service specific one. | Use environment db url, otherwise a service specific one.
| Python | mit | jawrainey/atc,jawrainey/atc |
8a43c573ebb606cfc6436396f2062fb9f00189d2 | asynctnt/__init__.py | asynctnt/__init__.py | from .connection import Connection, connect
from .iproto.protocol import Iterator, Response
__version__ = '0.1.5'
| from .connection import Connection, connect
from .iproto.protocol import Iterator, Response
__version__ = '0.1.6'
| Fix schema refetch bug. Version increase | Fix schema refetch bug. Version increase
| Python | apache-2.0 | igorcoding/asynctnt,igorcoding/asynctnt,igorcoding/asynctnt |
589598a9fc3871fe534e4dde60b61c9a0a56e224 | legistar/ext/pupa/orgs.py | legistar/ext/pupa/orgs.py | import pupa.scrape
from legistar.utils.itemgenerator import make_item
from legistar.ext.pupa.base import Adapter, Converter
class OrgsAdapter(Adapter):
'''Converts legistar data into a pupa.scrape.Person instance.
Note the make_item methods are popping values out the dict,
because the associated keys aren't valid pupa.scrape.Person fields.
'''
pupa_model = pupa.scrape.Organization
aliases = []
extras_keys = ['meeting_location', 'num_members', 'num_vacancies']
@make_item('classification')
def get_classn(self):
legistar_type = self.data.pop('type')
return self.config.get_org_classification(legistar_type)
class OrgsConverter(Converter):
'''Invokes the person and membership adapters to output pupa Person
objects.
'''
adapter = OrgsAdapter
def gen_agenda_items(self):
yield from self.make_child(AgendaItemConverter, self.agenda)
def __iter__(self):
self.agenda = self.data.pop('agenda', [])
yield self.get_adapter().get_instance()
yield from self.gen_agenda_items()
| import pupa.scrape
from legistar.utils.itemgenerator import make_item
from legistar.ext.pupa.base import Adapter, Converter
class OrgsAdapter(Adapter):
'''Converts legistar data into a pupa.scrape.Person instance.
Note the make_item methods are popping values out the dict,
because the associated keys aren't valid pupa.scrape.Person fields.
'''
pupa_model = pupa.scrape.Organization
aliases = []
extras_keys = [
'meeting_location', 'num_members', 'num_vacancies', 'type']
@make_item('classification')
def get_classn(self):
legistar_type = self.data.pop('type')
return self.config.get_org_classification(legistar_type)
def get_instance(self, **extra_instance_data):
instance_data = self.get_instance_data()
instance_data.update(extra_instance_data)
extras = instance_data.pop('extras')
sources = instance_data.pop('sources')
identifiers = instance_data.pop('identifiers')
instance = self.pupa_model(**instance_data)
instance.extras.update(extras)
for source in sources:
instance.add_source(**source)
for identifier in identifiers:
instance.add_identifier(**identifier)
return instance
class OrgsConverter(Converter):
'''Invokes the person and membership adapters to output pupa Person
objects.
'''
adapter = OrgsAdapter
| Remove cruft copied from Memberships adapter | Remove cruft copied from Memberships adapter
| Python | bsd-3-clause | opencivicdata/python-legistar-scraper,datamade/python-legistar-scraper |
42d06a15dd30e770dfccfccbd20fbf9bba52494d | platforms/m3/programming/goc_gdp_test.py | platforms/m3/programming/goc_gdp_test.py | #!/usr/bin/env python2
import code
try:
import Image
except ImportError:
from PIL import Image
import gdp
gdp.gdp_init()
gcl_name = gdp.GDP_NAME("edu.umich.eecs.m3.test01")
gcl_handle = gdp.GDP_GCL(gcl_name, gdp.GDP_MODE_RA)
#j = Image.open('/tmp/capture1060.jpeg')
#d = {"data": j.tostring()}
#gcl_handle.append(d)
record = gcl_handle.read(3)
raw = record['data']
image = Image.fromstring('RGB', (640,640), raw)
image.show()
#code.interact(local=locals())
| #!/usr/bin/env python2
import code
try:
import Image
except ImportError:
from PIL import Image
import gdp
gdp.gdp_init()
gcl_name = gdp.GDP_NAME("edu.umich.eecs.m3.test01")
gcl_handle = gdp.GDP_GCL(gcl_name, gdp.GDP_MODE_RA)
#j = Image.open('/tmp/capture1060.jpeg')
#d = {"data": j.tostring()}
#gcl_handle.append(d)
while True:
try:
idx = int(raw_input("Image index: "))
record = gcl_handle.read(idx)
raw = record['data']
image = Image.fromstring('RGB', (640,640), raw)
image.show()
except:
print("That image not availabe.")
#code.interact(local=locals())
| Update gdp test to open random images | Update gdp test to open random images
| Python | apache-2.0 | lab11/M-ulator,lab11/M-ulator,lab11/M-ulator,lab11/M-ulator,lab11/M-ulator,lab11/M-ulator,lab11/M-ulator |
e29039cf5b1cd0b40b8227ef73c2d5327450c162 | app/core/servicemanager.py | app/core/servicemanager.py | """
Contains components that manage services, their sequences and interdependence (later)
"""
import threading
import logging
logger = logging.getLogger(__name__)
class ServiceManager(threading.Thread):
"""
Sequentially starts services using service.service_start(). When a new
service is activated, view_manager is updated with its view.
"""
def __init__(self, services, socket_manager):
self.services = services
self.cur_service = None
self.socket_manager = socket_manager
super().__init__()
def run(self):
""" Sequentially starts all the services."""
logger.info("Starting services...")
for service_cls in self.services:
self.cur_service = service_cls(self.socket_manager)
self.cur_service.service_start()
| """
Contains components that manage services, their sequences and interdependence.
"""
import importlib
import logging
from collections import namedtuple
from app.core.toposort import toposort
logger = logging.getLogger(__name__)
Module = namedtuple('Module', ["name", "deps", "meta"])
def list_modules(module):
res = []
# for name in os.listdir(module.__path__):
for name in ["messaging"]:
module = importlib.import_module("app.services." + name)
module_meta = module.__meta__
deps = module_meta["deps"]
res.append(Module(name=name, deps=deps, meta=module_meta))
return res
def topo_sort_modules(modules):
module_map = {x.name: x for x in modules}
dep_map = {x.name: x.deps for x in modules}
res = []
for item in toposort(dep_map):
res.append(module_map[item])
return res
class ServiceManager(threading.Thread):
"""
Sequentially starts services using service.service_start(). When a new
service is activated, view_manager is updated with its view.
"""
def __init__(self, services, socket_manager):
self.services = services
self.cur_service = None
self.socket_manager = socket_manager
super().__init__()
def run(self):
""" Sequentially starts all the services."""
logger.info("Starting services...")
for service_cls in self.services:
self.cur_service = service_cls(self.socket_manager)
self.cur_service.service_start()
| Use toposort for sequencing services. | Use toposort for sequencing services.
| Python | mit | supersaiyanmode/HomePiServer,supersaiyanmode/HomePiServer,supersaiyanmode/HomePiServer |
fc1505865f919764aa066e5e43dcde1bc7e760b2 | frappe/patches/v13_0/rename_desk_page_to_workspace.py | frappe/patches/v13_0/rename_desk_page_to_workspace.py | import frappe
from frappe.model.rename_doc import rename_doc
def execute():
if frappe.db.exists("DocType", "Desk Page"):
if frappe.db.exists('DocType', 'Workspace'):
# this patch was not added initially, so this page might still exist
frappe.delete_doc('DocType', 'Desk Page')
else:
rename_doc('DocType', 'Desk Page', 'Workspace')
rename_doc('DocType', 'Desk Chart', 'Workspace Chart', ignore_if_exists=True)
rename_doc('DocType', 'Desk Link', 'Workspace Link', ignore_if_exists=True)
rename_doc('DocType', 'Desk Shortcut', 'Workspace Shortcut', ignore_if_exists=True)
frappe.reload_doc('desk', 'doctype', 'workspace')
| import frappe
from frappe.model.rename_doc import rename_doc
def execute():
if frappe.db.exists("DocType", "Desk Page"):
if frappe.db.exists('DocType', 'Workspace'):
# this patch was not added initially, so this page might still exist
frappe.delete_doc('DocType', 'Desk Page')
else:
rename_doc('DocType', 'Desk Page', 'Workspace')
rename_doc('DocType', 'Desk Chart', 'Workspace Chart', ignore_if_exists=True)
rename_doc('DocType', 'Desk Shortcut', 'Workspace Shortcut', ignore_if_exists=True)
if frappe.db.exist('DocType', 'Desk Link'):
rename_doc('DocType', 'Desk Link', 'Workspace Link', ignore_if_exists=True)
frappe.reload_doc('desk', 'doctype', 'workspace')
| Rename Desk Link only if it exists | fix(Patch): Rename Desk Link only if it exists
| Python | mit | frappe/frappe,StrellaGroup/frappe,StrellaGroup/frappe,saurabh6790/frappe,StrellaGroup/frappe,mhbu50/frappe,almeidapaulopt/frappe,yashodhank/frappe,saurabh6790/frappe,mhbu50/frappe,frappe/frappe,yashodhank/frappe,almeidapaulopt/frappe,mhbu50/frappe,saurabh6790/frappe,almeidapaulopt/frappe,almeidapaulopt/frappe,yashodhank/frappe,saurabh6790/frappe,mhbu50/frappe,frappe/frappe,yashodhank/frappe |
bac71c099f0196d5ab74a8ec08cedc32ab008e1c | graphite/post-setup-graphite-web.py | graphite/post-setup-graphite-web.py | #!/usr/bin/env python
import os
import random
import string
import sys
from django.utils.crypto import get_random_string
## Check if the script was already executed
flag_filename = '/opt/graphite/post-setup-complete'
if os.path.isfile(flag_filename):
sys.exit(0)
## Add SECRET_KEY to local_settings.py
settings_filename = '/opt/graphite/webapp/graphite/local_settings.py'
secret_key = get_random_string(
50, 'abcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*(-_=+)')
with open(settings_filename, 'a') as f:
f.write("SECRET_KEY = '%s'\n" % (secret_key, ))
if '--debug' in sys.argv:
f.write('DEBUG = True\n')
import django
django.setup()
from django.contrib.auth.models import User
## Create Superuser
password = ''.join(
(random.choice(string.letters + string.digits + string.punctuation))
for x in range(20))
User.objects.create_superuser('admin', 'admin@localhost', password)
print '[graphite-web] Superuser: admin, Password: %s' % (password, )
## Set flag file
with open(flag_filename, 'w'):
os.utime(flag_filename, None)
| #!/usr/bin/env python
import os
import random
import string
import sys
from django.utils.crypto import get_random_string
## Check if the script was already executed
flag_filename = '/opt/graphite/post-setup-complete'
if os.path.isfile(flag_filename):
sys.exit(0)
## Add SECRET_KEY to local_settings.py
settings_filename = '/opt/graphite/webapp/graphite/local_settings.py'
secret_key = get_random_string(
50, 'abcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*(-_=+)')
with open(settings_filename, 'a') as f:
f.write("SECRET_KEY = '%s'\n" % (secret_key, ))
if '--debug' in sys.argv:
f.write('DEBUG = True\n')
import django
django.setup()
from django.contrib.auth.models import User
## Create Superuser
password = ''.join(
(random.choice(string.letters + string.digits + string.punctuation))
for x in range(20))
if not User.objects.filter(username='admin').exists():
User.objects.create_superuser('admin', 'admin@localhost', password)
print '[graphite-web] Superuser: admin, Password: %s' % (password, )
## Set flag file
with open(flag_filename, 'w'):
os.utime(flag_filename, None)
| Check if admin user exists before creating one | Check if admin user exists before creating one
| Python | mit | rvernica/Dockerfile,rvernica/docker-library,rvernica/docker-library |
828fec30b5b1deddcca79eae8fd1029bd5bd7b54 | py/desispec/io/__init__.py | py/desispec/io/__init__.py | #
# See top-level LICENSE.rst file for Copyright information
#
# -*- coding: utf-8 -*-
"""
desispec.io
===========
Tools for data and metadata I/O.
"""
# help with 2to3 support
from __future__ import absolute_import, division
from .meta import findfile, get_exposures, get_files, rawdata_root, specprod_root
from .frame import read_frame, write_frame
from .sky import read_sky, write_sky
from .fiberflat import read_fiberflat, write_fiberflat
from .fibermap import read_fibermap, write_fibermap, empty_fibermap
from .brick import Brick
from .qa import read_qa_frame, write_qa_frame
from .zfind import read_zbest, write_zbest
from .image import read_image, write_image
from .util import (header2wave, fitsheader, native_endian, makepath,
write_bintable, iterfiles)
from .fluxcalibration import (
read_stdstar_templates, write_stdstar_model,
read_flux_calibration, write_flux_calibration)
from .filters import read_filter_response
from .download import download, filepath2url
from .crc import memcrc, cksum
from .database import (load_brick, is_night, load_night, is_flavor, load_flavor,
get_bricks_by_name, get_brickid_by_name, load_data)
| #
# See top-level LICENSE.rst file for Copyright information
#
# -*- coding: utf-8 -*-
"""
desispec.io
===========
Tools for data and metadata I/O.
"""
# help with 2to3 support
from __future__ import absolute_import, division
from .meta import (findfile, get_exposures, get_files, rawdata_root,
specprod_root, validate_night)
from .frame import read_frame, write_frame
from .sky import read_sky, write_sky
from .fiberflat import read_fiberflat, write_fiberflat
from .fibermap import read_fibermap, write_fibermap, empty_fibermap
from .brick import Brick
from .qa import read_qa_frame, write_qa_frame
from .zfind import read_zbest, write_zbest
from .image import read_image, write_image
from .util import (header2wave, fitsheader, native_endian, makepath,
write_bintable, iterfiles)
from .fluxcalibration import (
read_stdstar_templates, write_stdstar_model,
read_flux_calibration, write_flux_calibration)
from .filters import read_filter_response
from .download import download, filepath2url
from .crc import memcrc, cksum
from .database import (load_brick, is_night, load_night, is_flavor, load_flavor,
get_bricks_by_name, get_brickid_by_name, load_data)
| Add validate_night to public API | Add validate_night to public API
| Python | bsd-3-clause | desihub/desispec,gdhungana/desispec,timahutchinson/desispec,gdhungana/desispec,desihub/desispec,timahutchinson/desispec |
6699526ab04684ca9af3f6eb0f5361221e46e195 | src/purkinje/purkinje.py | src/purkinje/purkinje.py | #!/usr/bin/env python
from gevent.wsgi import WSGIServer
import werkzeug.serving
from werkzeug.debug import DebuggedApplication
from app import get_app
APP_PORT = 5000
DEBUG = True
@werkzeug.serving.run_with_reloader
def main():
"""Starts web application
"""
app = get_app()
app.debug = DEBUG
# app.config['ASSETS_DEBUG'] = DEBUG
http_server = WSGIServer(('', APP_PORT),
DebuggedApplication(app, evalex=True))
http_server.serve_forever()
# app.run()
if __name__ == '__main__':
print('purkinje ready')
main()
| #!/usr/bin/env python
import gevent.monkey
gevent.monkey.patch_all()
from gevent.wsgi import WSGIServer
import werkzeug.serving
from werkzeug.debug import DebuggedApplication
from app import get_app
APP_PORT = 5000
DEBUG = True
@werkzeug.serving.run_with_reloader
def main():
"""Starts web application
"""
app = get_app()
app.debug = DEBUG
# app.config['ASSETS_DEBUG'] = DEBUG
http_server = WSGIServer(('', APP_PORT),
DebuggedApplication(app, evalex=True))
http_server.serve_forever()
# app.run()
if __name__ == '__main__':
print('purkinje ready')
main()
| Apply gevent monkey patching, so it will get invoked when main is called via the entry point script and not via shell script | Apply gevent monkey patching, so it will get invoked when main
is called via the entry point script and not via shell script
| Python | mit | bbiskup/purkinje,bbiskup/purkinje,bbiskup/purkinje,bbiskup/purkinje |
a15513ee5fc45cb974129a9097ab0a7dbb9769fc | apps/metricsmanager/api.py | apps/metricsmanager/api.py | from rest_framework.views import APIView
from rest_framework.reverse import reverse
from rest_framework.response import Response
from rest_framework import generics
from rest_framework import generics, status
from django.core.exceptions import ValidationError
from .models import *
from .serializers import *
from .formula import validate_formula
class MetricsBase(APIView):
def get(self, request, format=None):
"""
:type request: Request
:param request:
:return:
"""
result = {
"Metrics": reverse('metrics-create', request=request)
}
return Response(result)
class FormulaValidate(APIView):
def get(self, request):
if "formula" not in request.QUERY_PARAMS:
return Response("No formula provided")
try:
validate_formula(request.QUERY_PARAMS["formula"])
return Response(status=status.HTTP_204_NO_CONTENT)
except ValidationError as e:
return Response(e, status=status.HTTP_400_BAD_REQUEST)
class MetricsCreate(generics.CreateAPIView):
model = Metric
serializer_class = MetricSerializer
class MetricsDetail(generics.RetrieveAPIView):
model = Metric
serializer_class = MetricSerializer
| from rest_framework.views import APIView
from rest_framework.reverse import reverse
from rest_framework.response import Response
from rest_framework import generics, status
from django.core.exceptions import ValidationError
from .models import *
from .serializers import *
from .formula import validate_formula
class MetricsBase(APIView):
def get(self, request, format=None):
"""
:type request: Request
:param request:
:return:
"""
result = {
"Metrics": reverse('metrics-create', request=request)
}
return Response(result)
class FormulaValidate(APIView):
def get(self, request):
if "formula" not in request.QUERY_PARAMS:
return Response("No formula provided")
try:
validate_formula(request.QUERY_PARAMS["formula"])
return Response(status=status.HTTP_204_NO_CONTENT)
except ValidationError as e:
return Response({ "formula": e.message }, status=status.HTTP_400_BAD_REQUEST)
class MetricsCreate(generics.CreateAPIView):
model = Metric
serializer_class = MetricSerializer
class MetricsDetail(generics.RetrieveAPIView):
model = Metric
serializer_class = MetricSerializer
| Change formula validation error to consistent form | Change formula validation error to consistent form
| Python | agpl-3.0 | almey/policycompass-services,mmilaprat/policycompass-services,mmilaprat/policycompass-services,policycompass/policycompass-services,almey/policycompass-services,almey/policycompass-services,policycompass/policycompass-services,policycompass/policycompass-services,mmilaprat/policycompass-services |
ae5a0b42ed6e0e44868e7a0e0a4d5901e2cf9e6b | src/info_retrieval/info_retrieval.py | src/info_retrieval/info_retrieval.py | # LING 573 Question Answering System
# Code last updated 4/17/14 by Clara Gordon
# This code implements an InfoRetriever for the question answering system.
from pymur import *
from general_classes import *
class InfoRetriever:
# builds a QueryEnvironment associated with the indexed document collection
def __init__(self, index_path):
# how to get this to link up to the doc collection?
self.path_to_idx = index_path
self.index = new Index(self.path_to_idx);
self.query_env = QueryEnvironment()
self.query_env.addIndex(self.path_to_idx)
# creates a list of all the passages returned by all the queries generated by
# the query-processing module
def retrieve_passages(self, queries):
passages = []
for query in queries:
# second argument is the number of documents desired
docs = self.query_env.runQuery("#combine[passage50:25](" + query + ")", 20)
for doc in docs:
doc_num = doc.document
begin = doc.begin
end = doc.end
doc_id = self.query_env.documents([doc_num])[0].metadata['docno'] # need this for output
passage = Passage(self.index.document(doc_num, True)[begin, end], doc.score, doc_id)
passages.append(passage)
return passages
| # LING 573 Question Answering System
# Code last updated 4/17/14 by Clara Gordon
# This code implements an InfoRetriever for the question answering system.
from pymur import *
from general_classes import *
class InfoRetriever:
# builds a QueryEnvironment associated with the indexed document collection
def __init__(self, index_path):
# how to get this to link up to the doc collection?
self.path_to_idx = index_path
self.index = new Index(self.path_to_idx)
self.query_env = QueryEnvironment()
self.query_env.addIndex(self.path_to_idx)
# creates a list of all the passages returned by all the queries generated by
# the query-processing module
def retrieve_passages(self, queries):
passages = []
for query in queries:
# second argument is the number of documents desired
docs = self.query_env.runQuery("#combine[passage50:25](" + query + ")", 20)
for doc in docs:
doc_num = doc.document
begin = doc.begin
end = doc.end
doc_id = self.query_env.documents([doc_num])[0].metadata['docno'] # need this for output
passage = Passage(self.index.document(doc_num, True)[begin, end], doc.score, doc_id)
passages.append(passage)
return passages
| Fix semicolon :/ in info_retriever | Fix semicolon :/ in info_retriever
| Python | mit | amkahn/question-answering,amkahn/question-answering |
caf4c29bada9d5b819d028469424ec195ffbc144 | tests/test_redefine_colors.py | tests/test_redefine_colors.py | #!/usr/bin/env python
# -*- coding: utf-8 -*-
"""Test redefinition of colors."""
import colorise
import pytest
@pytest.mark.skip_on_windows
def test_redefine_colors_error():
with pytest.raises(colorise.error.NotSupportedError):
colorise.redefine_colors({})
| #!/usr/bin/env python
# -*- coding: utf-8 -*-
"""Test redefinition of colors."""
import colorise
import pytest
@pytest.mark.skip_on_windows
def test_redefine_colors_error():
assert not colorise.can_redefine_colors()
with pytest.raises(colorise.error.NotSupportedError):
colorise.redefine_colors({})
| Test color redefinition on nix | Test color redefinition on nix
| Python | bsd-3-clause | MisanthropicBit/colorise |
6d2f9bfbe1011c04e014016171d98fef1d12e840 | tests/test_samtools_python.py | tests/test_samtools_python.py | import pysam
def test_idxstats_parse():
bam_filename = "./pysam_data/ex2.bam"
lines = pysam.idxstats(bam_filename)
for line in lines:
_seqname, _seqlen, nmapped, _nunmapped = line.split()
def test_bedcov():
bam_filename = "./pysam_data/ex1.bam"
bed_filename = "./pysam_data/ex1.bed"
lines = pysam.bedcov(bed_filename, bam_filename)
for line in lines:
fields = line.split('\t')
assert len(fields) in [4, 5], "bedcov should give tab delimited output with 4 or 5 fields. Split line (%s) gives %d fields." % (fields, len(fields))
| import pysam
def test_idxstats_parse_old_style_output():
bam_filename = "./pysam_data/ex2.bam"
lines = pysam.idxstats(bam_filename, old_style_output=True)
for line in lines:
_seqname, _seqlen, nmapped, _nunmapped = line.split()
def test_bedcov_old_style_output():
bam_filename = "./pysam_data/ex1.bam"
bed_filename = "./pysam_data/ex1.bed"
lines = pysam.bedcov(bed_filename, bam_filename, old_style_output=True)
for line in lines:
fields = line.split('\t')
assert len(fields) in [4, 5], "bedcov should give tab delimited output with 4 or 5 fields. Split line (%s) gives %d fields." % (fields, len(fields))
def test_idxstats_parse():
bam_filename = "./pysam_data/ex2.bam"
idxstats_string = pysam.idxstats(bam_filename, old_style_output=True)
lines = idxstats_string.splitlines()
for line in lines:
splt = line.split("\t")
_seqname, _seqlen, nmapped, _nunmapped = splt
def test_bedcov():
bam_filename = "./pysam_data/ex1.bam"
bed_filename = "./pysam_data/ex1.bed"
bedcov_string = pysam.bedcov(bed_filename, bam_filename, old_style_output=True)
lines = bedcov_string.splitlines()
for line in lines:
fields = line.split('\t')
assert len(fields) in [4, 5], "bedcov should give tab delimited output with 4 or 5 fields. Split line (%s) gives %d fields." % (fields, len(fields))
| Add test for both new and old style output | Add test for both new and old style output
| Python | mit | pysam-developers/pysam,kyleabeauchamp/pysam,pysam-developers/pysam,TyberiusPrime/pysam,bioinformed/pysam,TyberiusPrime/pysam,bioinformed/pysam,TyberiusPrime/pysam,pysam-developers/pysam,bioinformed/pysam,kyleabeauchamp/pysam,TyberiusPrime/pysam,kyleabeauchamp/pysam,kyleabeauchamp/pysam,kyleabeauchamp/pysam,pysam-developers/pysam,bioinformed/pysam,TyberiusPrime/pysam,bioinformed/pysam |
1ff19fcd0bcbb396b7cb676c5dddf8d3c8652419 | live/components/misc.py | live/components/misc.py | from live.helpers import Timer
def timed(fun, time, next_fun=None):
"""A component that runs another component for a fixed length of time. Can optionally be given a follow-up component for chaining.
:param callable fun: The component to be run:
:param number time: The amount of time to run the component
:keyword callable next_fun: A component to run after the timed component is finished
"""
timer = Timer(time)
def timed_callback(self, id):
nonlocal timer
if timer > 0.0:
fun(self, id)
else:
if next_fun:
self.logic_components.set(next_fun, id=id)
else:
self.logic_components.remove(id)
return timed_callback
def suspend(time, next_fun):
"""A component that suspends a component currently in the component list for a fixed length of time. Can optionally be given a different component to be run after the suspension is lifted.
:param number time: The amount of time to run the component
:keyword callable next_fun: A component to run after the suspension is lifted
"""
def suspend_callback(self, id):
pass
return timed(suspend_callback, time, next_fun ) | from live.helpers import Timer
def timed(fun, time, next_fun=None):
"""A component that runs another component for a fixed length of time. Can optionally be given a follow-up component for chaining.
:param callable fun: The component to be run:
:param number time: The amount of time to run the component
:keyword callable next_fun: A component to run after the timed component is finished
"""
timer = Timer(time)
def timed_callback(self, id, *args):
nonlocal timer
if timer > 0.0:
fun(self, id)
else:
if len(args) == 0:
correct_queue = self.logic_components
else:
correct_queue = self.collision_components
if next_fun:
correct_queue.set(next_fun, id=id)
else:
correct_queue.remove(id)
return timed_callback
def suspend(time, next_fun):
"""A component that suspends a component currently in the component list for a fixed length of time. Can optionally be given a different component to be run after the suspension is lifted.
:param number time: The amount of time to run the component
:keyword callable next_fun: A component to run after the suspension is lifted
"""
def suspend_callback(self, id):
pass
return timed(suspend_callback, time, next_fun ) | Update timed_callback to support collision callbacks. | Update timed_callback to support collision callbacks.
| Python | lgpl-2.1 | GalanCM/BGELive |
28ac2b259d89c168f1e822fe087c66f2f618321a | setup.py | setup.py | #!/usr/bin/env python
from distutils.core import setup
scripts = ['sed_fit', 'sed_plot', 'sed_filter_output', 'sed_fitinfo2data', 'sed_fitinfo2ascii']
setup(name='sedfitter',
version='0.1.1',
description='SED Fitter in python',
author='Thomas Robitaille',
author_email='[email protected]',
packages=['sedfitter', 'sedfitter.convolve', 'sedfitter.filter', 'sedfitter.sed', 'sedfitter.utils'],
scripts=['scripts/' + x for x in scripts]
)
| #!/usr/bin/env python
from distutils.core import setup
scripts = ['sed_fit', 'sed_plot', 'sed_filter_output', 'sed_fitinfo2data', 'sed_fitinfo2ascii']
setup(name='sedfitter',
version='0.1.1',
description='SED Fitter in python',
author='Thomas Robitaille',
author_email='[email protected]',
packages=['sedfitter', 'sedfitter.convolve', 'sedfitter.filter', 'sedfitter.sed', 'sedfitter.source', 'sedfitter.utils'],
scripts=['scripts/' + x for x in scripts]
)
| Add sedfitter.source to list of sub-packages to install (otherwise results in ImportError) | Add sedfitter.source to list of sub-packages to install (otherwise results in ImportError) | Python | bsd-2-clause | astrofrog/sedfitter |
3ef25d7105226aadebc5db46ac8c9c290d527164 | setup.py | setup.py | from setuptools import setup, find_packages
setup(
name='gdcdatamodel',
packages=find_packages(),
install_requires=[
'pytz==2016.4',
'graphviz==0.4.2',
'jsonschema==2.5.1',
'psqlgraph',
'gdcdictionary',
'cdisutils',
'python-dateutil==2.4.2',
],
package_data={
"gdcdatamodel": [
"xml_mappings/*.yaml",
]
},
dependency_links=[
'git+https://github.com/NCI-GDC/cdisutils.git@4a75cc05c7ba2174e70cca9c9ea7e93947f7a868#egg=cdisutils',
'git+https://github.com/NCI-GDC/psqlgraph.git@7b5de7d56aa3159a9526940eb273579ddbf084ca#egg=psqlgraph',
'git+https://github.com/NCI-GDC/gdcdictionary.git@release/horton#egg=gdcdictionary',
],
entry_points={
'console_scripts': [
'gdc_postgres_admin=gdcdatamodel.gdc_postgres_admin:main'
]
},
)
| from setuptools import setup, find_packages
setup(
name='gdcdatamodel',
packages=find_packages(),
install_requires=[
'pytz==2016.4',
'graphviz==0.4.2',
'jsonschema==2.5.1',
'psqlgraph',
'gdcdictionary',
'cdisutils',
'python-dateutil==2.4.2',
],
package_data={
"gdcdatamodel": [
"xml_mappings/*.yaml",
]
},
dependency_links=[
'git+https://github.com/NCI-GDC/cdisutils.git@4a75cc05c7ba2174e70cca9c9ea7e93947f7a868#egg=cdisutils',
'git+https://github.com/NCI-GDC/psqlgraph.git@7b5de7d56aa3159a9526940eb273579ddbf084ca#egg=psqlgraph',
'git+https://github.com/NCI-GDC/gdcdictionary.git@6d404dbd1dd45ed35d0aef6d33c43dbbd982930d#egg=gdcdictionary',
],
entry_points={
'console_scripts': [
'gdc_postgres_admin=gdcdatamodel.gdc_postgres_admin:main'
]
},
)
| Update dictionary to same pin as API for Horton | chore(pins): Update dictionary to same pin as API for Horton
- Update dictionary to the same pin as the API uses
| Python | apache-2.0 | NCI-GDC/gdcdatamodel,NCI-GDC/gdcdatamodel |
1a12f250088d92544a277e3d683dc397687a4188 | setup.py | setup.py | #!/usr/bin/env python
# Copyright 2009-2014 Eucalyptus Systems, Inc.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
try:
from setuptools import setup, find_packages
except ImportError:
from distutils.core import setup
setup(name='deploymentmanager',
version='0.1',
description='Eucalyptus Deployment and Configuration Management tools',
url='https://github.com/eucalyptus/DeploymentManager.git',
license='Apache License 2.0',
packages=find_packages(),
install_requires=['paramiko', 'PrettyTable', 'eve', 'requests',
'Flask-Bootstrap', 'eve', 'PrettyTable', 'argparse', 'nose', 'httpretty'],
test_suite="nose.collector",
zip_safe=False,
classifiers=[
"Development Status :: 1 - Alpha",
"Topic :: Utilities",
"Environment :: Console",
],
)
| #!/usr/bin/env python
# Copyright 2009-2014 Eucalyptus Systems, Inc.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
try:
from setuptools import setup, find_packages
except ImportError:
from distutils.core import setup
setup(name='deploymentmanager',
version='0.1',
description='Eucalyptus Deployment and Configuration Management tools',
url='https://github.com/eucalyptus/DeploymentManager.git',
license='Apache License 2.0',
packages=find_packages(),
install_requires=['paramiko', 'PrettyTable', 'eve', 'requests', 'mock',
'Flask-Bootstrap', 'eve', 'PrettyTable', 'argparse', 'nose', 'httpretty'],
test_suite="nose.collector",
zip_safe=False,
classifiers=[
"Development Status :: 1 - Alpha",
"Topic :: Utilities",
"Environment :: Console",
],
)
| Add mock as a dep | Add mock as a dep
| Python | apache-2.0 | ccassler/DeploymentManager,tbeckham/DeploymentManager,tbeckham/DeploymentManager,ccassler/DeploymentManager,tbeckham/DeploymentManager,ccassler/DeploymentManager |
8cbbf6b4b4b1cc87f25b2047e183dd1bfd7dc8a0 | setup.py | setup.py | #!/usr/bin/env python
# Copyright (c) 2013 Hewlett-Packard Development Company, L.P.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
# implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# THIS FILE IS MANAGED BY THE GLOBAL REQUIREMENTS REPO - DO NOT EDIT
import setuptools
setuptools.setup(
setup_requires=['pbr'],
pbr=True)
| #!/usr/bin/env python
# Copyright (c) 2013 Hewlett-Packard Development Company, L.P.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
# implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import setuptools
setuptools.setup(
setup_requires=['pbr'],
pbr=True)
| Remove incorrect note about global reqs | Remove incorrect note about global reqs
| Python | apache-2.0 | Frostman/SalaryZenAggregator_Old,Frostman/SalaryZenAggregator |
b6af395f816609801e1973b56c61dc5fc52d49d0 | setup.py | setup.py | #!/usr/bin/env python3.8
# Copyright (C) 2017-2019 Andrew Hamilton. All rights reserved.
# Licensed under the Artistic License 2.0.
try:
from setuptools import setup
except ImportError:
from distutils.core import setup
setup(name="eris",
version="18.12",
description=("Eris maintains an up-to-date set of reports for every"
" file in a codebase."),
url="https://github.com/ahamilton/eris",
author="Andrew Hamilton",
license="Artistic 2.0",
packages=["eris", "eris.urwid"],
package_data={"eris": ["LS_COLORS.sh", "tools.toml"]},
entry_points={"console_scripts":
["eris=eris.__main__:entry_point",
"eris-worker=eris.worker:main",
"eris-webserver=eris.webserver:main",
"pydoc_color=eris.pydoc_color:main"]})
| #!/usr/bin/env python3.8
# Copyright (C) 2017-2019 Andrew Hamilton. All rights reserved.
# Licensed under the Artistic License 2.0.
try:
from setuptools import setup
except ImportError:
from distutils.core import setup
setup(name="eris",
version="20.04",
description=("Eris maintains an up-to-date set of reports for every"
" file in a codebase."),
url="https://github.com/ahamilton/eris",
author="Andrew Hamilton",
license="Artistic 2.0",
packages=["eris", "eris.urwid"],
package_data={"eris": ["LS_COLORS.sh", "tools.toml"]},
entry_points={"console_scripts":
["eris=eris.__main__:entry_point",
"eris-worker=eris.worker:main",
"eris-webserver=eris.webserver:main",
"pydoc_color=eris.pydoc_color:main"]})
| Bring version number up to date. | Bring version number up to date.
| Python | artistic-2.0 | ahamilton/vigil,ahamilton/vigil,ahamilton/vigil,ahamilton/vigil,ahamilton/vigil,ahamilton/vigil,ahamilton/vigil,ahamilton/vigil,ahamilton/vigil |
ad579b09e691811a39714f816721bba615dcc651 | setup.py | setup.py | """Utiltiy functions for workign on the NinaPro Databases (1 & 2)."""
from setuptools import setup, find_packages
setup(name='nina_helper',
version='2.1',
description='Utiltiy functions for workign on the NinaPro Databases (1 & 2)',
author='Lif3line',
author_email='[email protected]',
license='MIT',
packages=find_packages(),
url='https://github.com/Lif3line/nina_helper_package_mk2', # use the URL to the github repo
download_url='https://github.com/Lif3line/nina_helper_package_mk2/archive/2.1.tar.gz', # Hack github address
install_requires=[
'os',
'scipy',
'sklearn',
'itertools',
'numpy'
],
keywords='ninapro emg')
| """Utiltiy functions for workign on the NinaPro Databases (1 & 2)."""
from setuptools import setup, find_packages
setup(name='nina_helper',
version='2.2',
description='Utiltiy functions for workign on the NinaPro Databases (1 & 2)',
author='Lif3line',
author_email='[email protected]',
license='MIT',
packages=find_packages(),
url='https://github.com/Lif3line/nina_helper_package_mk2', # use the URL to the github repo
# download_url='https://github.com/Lif3line/nina_helper_package_mk2/archive/2.2.tar.gz', # Hack github address
install_requires=[
'scipy',
'sklearn',
'numpy'
],
keywords='ninapro emg')
| Use local upload for release | Use local upload for release
| Python | mit | Lif3line/nina_helper_package_mk2 |
4c1ec733615b0fd21677f8b4e9a8acd9381dff53 | setup.py | setup.py | from setuptools import setup, Extension, find_packages
from Cython.Build import cythonize
# Cython extensions
sources = ["FastxIO/fastx.pyx", "FastxIO/reverse_complement.c"]
extensions = [Extension("FastxIO.fastx", sources, extra_compile_args=['-O3'])]
setup(
name = "FastxIO",
version = '0.0.0',
packages = find_packages(exclude=['tests']),
ext_modules = cythonize(extensions),
description = "Read FASTA and FASTQ files.",
author = "Marcus Kinsella",
license = "MIT",
install_requires = [
'cython'
],
)
| from setuptools import setup, Extension, find_packages
from Cython.Build import cythonize
# Cython extensions
sources = ["FastxIO/fastx.pyx", "FastxIO/reverse_complement.c"]
extensions = [Extension("FastxIO.fastx",
sources,
extra_compile_args=['-O3'],
libraries=["z"])]
setup(
name = "FastxIO",
version = '0.0.0',
packages = find_packages(exclude=['tests']),
ext_modules = cythonize(extensions),
description = "Read FASTA and FASTQ files.",
author = "Marcus Kinsella",
license = "MIT",
install_requires = [
'cython'
],
)
| Add -lz to cython flags. | Add -lz to cython flags.
| Python | mit | mckinsel/FastxIO,mckinsel/FastxIO |
b5523a7f3bfd67eac646ee1313bcbb6c9e069f8c | setup.py | setup.py | # Copyright 2015 UnitedStack, Inc.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from setuptools import setup, find_packages
setup(name='stetho',
version="0.1.0",
packages = find_packages(),
zip_safe = False,
description = "stetho",
author = "UnitedStackSDN",
author_email = "[email protected]",
license = "APL",
keywords = ("stetho", "egg"),
platforms = "Independant",
url = "https://www.ustack.com",
entry_points={
'console_scripts': [
'stetho = stetho.stethoclient.shell:main'
]
}
)
| # Copyright 2015 UnitedStack, Inc.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from setuptools import setup, find_packages
setup(name='stetho',
version="0.1.0",
packages = find_packages(),
zip_safe = False,
description = "stetho",
author = "UnitedStackSDN",
author_email = "[email protected]",
license = "APL",
keywords = ("stetho", "egg"),
platforms = "Independant",
url = "https://www.ustack.com",
entry_points={
'console_scripts': [
'stetho = stetho.stethoclient.shell:main',
'stetho-agent = stetho.agent.agent:main',
]
}
)
| Make stetho agent when install stetho | Make stetho agent when install stetho
| Python | apache-2.0 | unitedstack/stetho,unitedstack/stetho,openstack/steth,openstack/steth |
c8bf52d51a5cc678160add7db937ed92aaa6bb09 | setup.py | setup.py | from setuptools import setup, find_packages
setup(
name='gdcdatamodel',
packages=find_packages(),
install_requires=[
'pytz==2016.4',
'graphviz==0.4.2',
'jsonschema==2.5.1',
'psqlgraph',
'gdcdictionary',
'cdisutils',
'python-dateutil==2.4.2',
],
package_data={
"gdcdatamodel": [
"xml_mappings/*.yaml",
]
},
dependency_links=[
'git+https://github.com/NCI-GDC/cdisutils.git@4a75cc05c7ba2174e70cca9c9ea7e93947f7a868#egg=cdisutils',
'git+https://github.com/NCI-GDC/psqlgraph.git@7b5de7d56aa3159a9526940eb273579ddbf084ca#egg=psqlgraph',
'git+https://github.com/NCI-GDC/gdcdictionary.git@86a4e6dd7b78d50ec17dc4bcdd1a3d25c658b88b#egg=gdcdictionary',
],
entry_points={
'console_scripts': [
'gdc_postgres_admin=gdcdatamodel.gdc_postgres_admin:main'
]
},
)
| from setuptools import setup, find_packages
setup(
name='gdcdatamodel',
packages=find_packages(),
install_requires=[
'pytz==2016.4',
'graphviz==0.4.2',
'jsonschema==2.5.1',
'psqlgraph',
'gdcdictionary',
'cdisutils',
'python-dateutil==2.4.2',
],
package_data={
"gdcdatamodel": [
"xml_mappings/*.yaml",
]
},
dependency_links=[
'git+https://github.com/NCI-GDC/cdisutils.git@4a75cc05c7ba2174e70cca9c9ea7e93947f7a868#egg=cdisutils',
'git+https://github.com/NCI-GDC/psqlgraph.git@7b5de7d56aa3159a9526940eb273579ddbf084ca#egg=psqlgraph',
'git+https://github.com/NCI-GDC/gdcdictionary.git@release/horton#egg=gdcdictionary',
],
entry_points={
'console_scripts': [
'gdc_postgres_admin=gdcdatamodel.gdc_postgres_admin:main'
]
},
)
| Update to point to release/horton | chore(pins): Update to point to release/horton
- Update to point to release/horton of gdcdictionary
| Python | apache-2.0 | NCI-GDC/gdcdatamodel,NCI-GDC/gdcdatamodel |
873572d6731d35647dca90b4aea4d7f26866f676 | setup.py | setup.py | from setuptools import setup
version = '0.4.2'
setup(
name='sqlalchemy-vertica-python',
version=version,
description='Vertica dialect for sqlalchemy using vertica_python',
long_description=open("README.rst").read(),
license="MIT",
url='https://github.com/LocusEnergy/sqlalchemy-vertica-python',
download_url = 'https://github.com/LocusEnergy/sqlalchemy-vertica-python/tarball/{}'.format(version),
author='Locus Energy',
author_email='[email protected]',
packages=[
'sqla_vertica_python',
],
entry_points="""
[sqlalchemy.dialects]
vertica.vertica_python = sqla_vertica_python.vertica_python:VerticaDialect
""",
install_requires=[
'vertica_python'
],
)
| from setuptools import setup
version = '0.4.2'
setup(
name='sqlalchemy-vertica-python',
version=version,
description='Vertica dialect for sqlalchemy using vertica_python',
long_description=open("README.rst").read(),
license="MIT",
url='https://github.com/LocusEnergy/sqlalchemy-vertica-python',
download_url = 'https://github.com/LocusEnergy/sqlalchemy-vertica-python/tarball/{}'.format(version),
author='Locus Energy',
author_email='[email protected]',
packages=[
'sqla_vertica_python',
],
entry_points="""
[sqlalchemy.dialects]
vertica.vertica_python = sqla_vertica_python.vertica_python:VerticaDialect
""",
install_requires=[
'vertica_python[namedparams]'
],
)
| Add optional named parameters dependencies for vertica-python | Add optional named parameters dependencies for vertica-python
This will allow to play nicely with sqlalchemy-vertica-python and safrs
Ref: https://github.com/vertica/vertica-python/pull/247 | Python | mit | LocusEnergy/sqlalchemy-vertica-python |
4a7221a67b23933a2e9314f3bbd2b886d7276b7d | setup.py | setup.py | #!/usr/bin/env python
import setuptools
with open("README.md", "r") as fh:
long_description = fh.read()
setuptools.setup(
name="autograd-gamma",
version="0.4.2",
description="Autograd compatible approximations to the gamma family of functions",
author="Cameron Davidson-Pilon",
author_email="[email protected]",
url="https://github.com/CamDavidsonPilon/autograd-gamma",
keywords=["autograd", "gamma", "incomplete gamma function"],
long_description=long_description,
long_description_content_type="text/markdown",
classifiers=[
"Intended Audience :: Science/Research",
"Topic :: Scientific/Engineering",
"Programming Language :: Python :: 2",
"Programming Language :: Python :: 3",
],
install_requires=["autograd>=1.2.0", "scipy>=1.2.0"],
packages=setuptools.find_packages(),
)
| #!/usr/bin/env python
import setuptools
with open("README.md", "r") as fh:
long_description = fh.read()
setuptools.setup(
name="autograd-gamma",
version="0.4.2",
description="Autograd compatible approximations to the gamma family of functions",
license='MIT License',
author="Cameron Davidson-Pilon",
author_email="[email protected]",
url="https://github.com/CamDavidsonPilon/autograd-gamma",
keywords=["autograd", "gamma", "incomplete gamma function"],
long_description=long_description,
long_description_content_type="text/markdown",
classifiers=[
"Intended Audience :: Science/Research",
"Topic :: Scientific/Engineering",
"Programming Language :: Python :: 2",
"Programming Language :: Python :: 3",
],
install_requires=["autograd>=1.2.0", "scipy>=1.2.0"],
packages=setuptools.find_packages(),
)
| Add license to package metadata | Add license to package metadata | Python | mit | CamDavidsonPilon/autograd-gamma |
d2cc077bfce9bef654a8ef742996e5aca8858fc7 | setup.py | setup.py | from distutils.core import setup
setup(name='Pyranha',
description='Elegant IRC client',
version='0.1',
author='John Reese',
author_email='[email protected]',
url='https://github.com/jreese/pyranha',
classifiers=['License :: OSI Approved :: MIT License',
'Topic :: Communications :: Chat :: Internet Relay Chat',
'Development Status :: 2 - Pre-Alpha',
],
license='MIT License',
packages=['pyranha', 'pyranha.irc'],
package_data={'pyranha': []},
scripts=['bin/pyranha'],
)
| from distutils.core import setup
setup(name='Pyranha',
description='Elegant IRC client',
version='0.1',
author='John Reese',
author_email='[email protected]',
url='https://github.com/jreese/pyranha',
classifiers=['License :: OSI Approved :: MIT License',
'Topic :: Communications :: Chat :: Internet Relay Chat',
'Development Status :: 2 - Pre-Alpha',
],
license='MIT License',
packages=['pyranha', 'pyranha.irc'],
package_data={'pyranha': ['dotfiles/*']},
scripts=['bin/pyranha'],
)
| Install default dotfiles with package | Install default dotfiles with package
| Python | mit | jreese/pyranha |
eb2827a94e477c64eeb67076288007326c34a2f9 | setup.py | setup.py | """setup.py"""
from codecs import open as codecs_open
from setuptools import setup
with codecs_open('README.rst', 'r', 'utf-8') as f:
__README = f.read()
with codecs_open('HISTORY.rst', 'r', 'utf-8') as f:
__HISTORY = f.read()
setup(
name='jsonrpcclient',
version='2.2.4',
description='Send JSON-RPC requests',
long_description=__README+'\n\n'+__HISTORY,
author='Beau Barker',
author_email='[email protected]',
url='https://jsonrpcclient.readthedocs.io/',
license='MIT',
packages=['jsonrpcclient'],
package_data={'jsonrpcclient': ['response-schema.json']},
include_package_data=True,
install_requires=['future', 'jsonschema'],
extras_require={
'requests': ['requests'],
'requests_security': ['requests[security]'],
'zmq': ['pyzmq'],
'tornado': ['tornado'],
'unittest': ['requests', 'pyzmq', 'tornado', 'responses', \
'testfixtures', 'mock']
},
classifiers=[
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3.3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6'
],
)
| """setup.py"""
from codecs import open as codecs_open
from setuptools import setup
with codecs_open('README.rst', 'r', 'utf-8') as f:
__README = f.read()
with codecs_open('HISTORY.rst', 'r', 'utf-8') as f:
__HISTORY = f.read()
setup(
name='jsonrpcclient',
version='2.2.4',
description='Send JSON-RPC requests',
long_description=__README+'\n\n'+__HISTORY,
author='Beau Barker',
author_email='[email protected]',
url='https://jsonrpcclient.readthedocs.io/',
license='MIT',
packages=['jsonrpcclient'],
package_data={'jsonrpcclient': ['response-schema.json']},
include_package_data=True,
install_requires=['future', 'jsonschema'],
extras_require={
'aiohttp': ['aiohttp'],
'requests': ['requests'],
'requests_security': ['requests[security]'],
'tornado': ['tornado'],
'unittest': ['requests', 'pyzmq', 'tornado', 'responses', \
'testfixtures', 'mock']
'websockets': ['websockets'],
'zmq': ['pyzmq'],
},
classifiers=[
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3.3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6'
],
)
| Add aiohttpClient plus example usage | Add aiohttpClient plus example usage
Closes #20
| Python | mit | bcb/jsonrpcclient |
6ca0407f1666a67478832bc72f0ac740cb699598 | setup.py | setup.py | from setuptools import setup
setup(
name='ChannelWorm',
long_description=open('README.md').read(),
install_requires=[
'cypy',
'sciunit',
'PyOpenWorm',
'PyNeuroML>=0.0.6'
],
dependency_links=[
'git+https://github.com/scidash/sciunit.git#egg=sciunit',
'git+https://github.com/openworm/PyOpenWorm.git#egg=PyOpenWorm',
'git+https://github.com/NeuroML/pyNeuroML.git#egg=PyNeuroML@5aeab1243567d9f4a8ce16516074dc7b93dfbf37'
]
)
| from setuptools import setup
setup(
name='ChannelWorm',
long_description=open('README.md').read(),
install_requires=[
'cypy',
'sciunit',
'PyOpenWorm',
'PyNeuroML>=0.0.5'
],
dependency_links=[
'git+https://github.com/scidash/sciunit.git#egg=sciunit',
'git+https://github.com/openworm/PyOpenWorm.git#egg=PyOpenWorm',
'git+https://github.com/NeuroML/pyNeuroML.git#egg=PyNeuroML'
]
)
| Revert to installing PyNeuroML without version specification | Revert to installing PyNeuroML without version specification
| Python | mit | joebowen/ChannelWorm,joebowen/ChannelWorm,VahidGh/ChannelWorm,openworm/ChannelWorm,joebowen/ChannelWorm,joebowen/ChannelWormDjango,openworm/ChannelWorm,joebowen/ChannelWorm,gsarma/ChannelWorm,VahidGh/ChannelWorm,openworm/ChannelWorm,joebowen/ChannelWormDjango,joebowen/ChannelWormDjango,cheelee/ChannelWorm,gsarma/ChannelWorm,cheelee/ChannelWorm,gsarma/ChannelWorm,joebowen/ChannelWormDjango,openworm/ChannelWorm,cheelee/ChannelWorm,VahidGh/ChannelWorm,gsarma/ChannelWorm,VahidGh/ChannelWorm,cheelee/ChannelWorm |
2e9808561c55a729fef493b03e5bcdd13422a92c | setup.py | setup.py | """
edx-lint
========
A collection of code quality tools:
- A few pylint plugins to check for quality issues pylint misses.
- A command-line tool to generate config files like pylintrc from a master
file (part of edx_lint), and a repo-specific tweaks file.
"""
from setuptools import setup
setup(
setup_requires=['pbr>=1.9', 'setuptools>=17.1'],
pbr=True,
)
| """
edx-lint
========
A collection of code quality tools:
- A few pylint plugins to check for quality issues pylint misses.
- A command-line tool to generate config files like pylintrc from a master
file (part of edx_lint), and a repo-specific tweaks file.
"""
import os
from setuptools import setup
# pbr does some things we don't need. Turn them off the only way pbr gives us.
os.environ['SKIP_GENERATE_AUTHORS'] = '1'
os.environ['SKIP_WRITE_GIT_CHANGELOG'] = '1'
setup(
setup_requires=['pbr>=1.9', 'setuptools>=17.1'],
pbr=True,
)
| Stop pbr from writing ChangeLog and AUTHORS | Stop pbr from writing ChangeLog and AUTHORS
| Python | apache-2.0 | edx/edx-lint |
0b5e16ad77aebdde05dbffef78265755c779bb8b | setup.py | setup.py | from setuptools import setup, find_packages
import os
version = '0.5.1'
here = os.path.abspath(os.path.dirname(__file__))
try:
README = open(os.path.join(here, 'README.txt')).read()
CHANGES = open(os.path.join(here, 'docs/HISTORY.txt')).read()
except IOError:
README = CHANGES = ''
setup(name='tgext.admin',
version=version,
description="Admin Controller add-on for basic TG identity model.",
long_description=README + "\n" +
CHANGES,
# Get more strings from http://www.python.org/pypi?%3Aaction=list_classifiers
classifiers=[
"Programming Language :: Python",
"Topic :: Software Development :: Libraries :: Python Modules",
],
keywords='turbogears2.extension, TG2, TG, sprox, Rest, internet, admin',
author='Christopher Perkins',
author_email='[email protected]',
url='tgtools.googlecode.com',
license='MIT',
packages=find_packages(exclude=['ez_setup']),
namespace_packages=['tgext'],
include_package_data=True,
zip_safe=True,
install_requires=[
'setuptools',
'tgext.crud>=0.4',
# -*- Extra requirements: -*-
],
entry_points="""
# -*- Entry points: -*-
""",
)
| from setuptools import setup, find_packages
import os
version = '0.5.1'
here = os.path.abspath(os.path.dirname(__file__))
try:
README = open(os.path.join(here, 'README.txt')).read()
CHANGES = open(os.path.join(here, 'docs/HISTORY.txt')).read()
except IOError:
README = CHANGES = ''
setup(name='tgext.admin',
version=version,
description="Admin Controller add-on for basic TG identity model.",
long_description=README + "\n" +
CHANGES,
# Get more strings from http://www.python.org/pypi?%3Aaction=list_classifiers
classifiers=[
"Programming Language :: Python",
"Topic :: Software Development :: Libraries :: Python Modules",
],
keywords='turbogears2.extension, TG2, TG, sprox, Rest, internet, admin',
author='Christopher Perkins',
author_email='[email protected]',
url='tgtools.googlecode.com',
license='MIT',
packages=find_packages(exclude=['ez_setup']),
namespace_packages=['tgext'],
include_package_data=True,
zip_safe=True,
install_requires=[
'setuptools',
'tgext.crud>=0.5.1',
# -*- Extra requirements: -*-
],
entry_points="""
# -*- Entry points: -*-
""",
)
| Make it work with new tg Jinja quickstart | Make it work with new tg Jinja quickstart
| Python | mit | TurboGears/tgext.admin,TurboGears/tgext.admin |
a890b8099779aaece5cb3a963c9b86bb3f8156f7 | setup.py | setup.py | from setuptools import setup, find_packages
from itertools import imap, ifilter
from os import path
from ast import parse
if __name__ == '__main__':
package_name = 'gitim'
get_vals = lambda var0, var1: imap(lambda buf: next(imap(lambda e: e.value.s, parse(buf).body)),
ifilter(lambda line: line.startswith(var0) or line.startswith(var1), f))
with open('gitim.py') as f:
__author__, __version__ = get_vals('__version__', '__author__')
setup(
name=package_name,
author=__author__,
version=__version__,
license='MIT',
install_requires=['pygithub'],
py_modules=['gitim']
)
| from setuptools import setup, find_packages
try:
from itertools import imap, ifilter
except ImportError:
imap = map
ifilter = filter
from os import path
from ast import parse
if __name__ == '__main__':
package_name = 'gitim'
get_vals = lambda var0, var1: imap(lambda buf: next(imap(lambda e: e.value.s, parse(buf).body)),
ifilter(lambda line: line.startswith(var0) or line.startswith(var1), f))
with open('gitim.py') as f:
__author__, __version__ = get_vals('__version__', '__author__')
setup(
name=package_name,
author=__author__,
version=__version__,
license='MIT',
install_requires=['pygithub'],
py_modules=['gitim']
)
| Use native `map`, `filter` for Python 3 | Use native `map`, `filter` for Python 3
| Python | mit | muhasturk/gitim |
Subsets and Splits