prompt
large_stringlengths
72
9.34k
completion
large_stringlengths
0
7.61k
<|file_name|>TutorialTVScenes.py<|end_file_name|><|fim▁begin|># Fuck you Disyer. Stealing my fucking paypal. GET FUCKED: toontown.tutorial.TutorialTVScenes from panda3d.core import Camera from direct.task.Task import Task from otp.avatar import Emote from toontown.television.TVScenes import * from toontown.television.TVEffects import * from toontown.suit.Suit import Suit from toontown.suit.BossCog import BossCog from toontown.suit.SuitDNA import SuitDNA from toontown.toon import NPCToons, TTEmote import random class CEOScene(ThreeDScene): CameraPos = [(0, 203.5, 23.5, 0, 350, 0)] def __init__(self, effects = []): ThreeDScene.__init__(self, 'CEOScene', effects) self.geom = loader.loadModel('phase_12/models/bossbotHQ/BanquetInterior_1') self.geom.reparentTo(self) self.ceo = BossCog() dna = SuitDNA() dna.newBossCog('c') self.ceo.setDNA(dna) self.ceo.reparentTo(self) self.ceo.setPosHpr(0, 236.5, 0, 180, 0, 0) self.ceo.loop('Bb_neutral') def delete(self): if self.geom: self.geom.removeNode() self.geom = None if self.ceo: self.ceo.delete() self.ceo = None ThreeDScene.delete(self) return class HeadHunterScene(ThreeDScene): CameraPos = [(-22, -12.5, 7, 92, -6, 0)] def __init__(self, effects = []): ThreeDScene.__init__(self, 'HeadHunterScene', effects) self.geom = loader.loadModel('phase_12/models/bossbotHQ/BossbotEntranceRoom') self.geom.reparentTo(self) self.cog = Suit() dna = SuitDNA() dna.newSuit('hh') self.cog.setDNA(dna) self.cog.reparentTo(self) self.cog.setPosHpr(-32.5, -12.5, 0.02, 270, 0, 0) self.cog.nametag3d.removeNode() self.cog.nametag.destroy() self.cog.loop('neutral') def delete(self): if self.geom: self.geom.removeNode() self.geom = None if self.cog: self.cog.delete() self.cog = None ThreeDScene.delete(self) return class ScientistScene(ThreeDScene): CameraPos = [(-47.5, 0.5, 3.415, 90, 0, 0)] ToonPos = {2018: (-59, -1.5, 0.02, 270, 0, 0), 2019: (-59, 0.5, 0.02, 270, 0, 0), 2020: (-59, 2.5, 0.02, 270, 0, 0)} RandomEmotes = ['wave', 'angry', 'applause', 'cringe', 'confused', 'slip-forward', 'slip-backward', 'resistance-salute', 'surprise', 'cry', 'furious', 'laugh', 'idea', 'taunt', 'rage'] def __init__(self, effects = []): ThreeDScene.__init__(self, 'ScientistScene', effects) self.geom = loader.loadModel('phase_3.5/models/modules/tt_m_ara_int_toonhall') self.geom.reparentTo(self) self.taskStarted = False self.npcs = [] for id, posHpr in self.ToonPos.iteritems(): npc = NPCToons.createLocalNPC(id) npc.reparentTo(self.geom) npc.setPosHpr(*posHpr) npc.nametag3d.removeNode() npc.nametag.destroy() self.npcs.append(npc) def delete(self): if self.geom: self.geom.removeNode() self.geom = None for npc in self.npcs: taskMgr.remove(npc.uniqueName('randomEmote')) npc.delete() self.npcs = [] self.taskStarted = False ThreeDScene.delete(self) return def <|fim_middle|>(self): if self.taskStarted: return for i, npc in enumerate(self.npcs): taskMgr.doMethodLater(0.25 * i, lambda task, npc = npc: self.doRandomEmote(npc, task), npc.uniqueName('randomEmote')) self.taskStarted = True def stopTask(self): if not self.taskStarted: return for npc in self.npcs: taskMgr.remove(npc.uniqueName('randomEmote')) self.taskStarted = False def doRandomEmote(self, npc, task): Emote.globalEmote.doEmote(npc, TTEmote.Emotes.index(random.choice(self.RandomEmotes)), 0) task.delayTime = npc.emoteTrack.getDuration() + 1.0 return task.again<|fim▁end|>
startTask
<|file_name|>TutorialTVScenes.py<|end_file_name|><|fim▁begin|># Fuck you Disyer. Stealing my fucking paypal. GET FUCKED: toontown.tutorial.TutorialTVScenes from panda3d.core import Camera from direct.task.Task import Task from otp.avatar import Emote from toontown.television.TVScenes import * from toontown.television.TVEffects import * from toontown.suit.Suit import Suit from toontown.suit.BossCog import BossCog from toontown.suit.SuitDNA import SuitDNA from toontown.toon import NPCToons, TTEmote import random class CEOScene(ThreeDScene): CameraPos = [(0, 203.5, 23.5, 0, 350, 0)] def __init__(self, effects = []): ThreeDScene.__init__(self, 'CEOScene', effects) self.geom = loader.loadModel('phase_12/models/bossbotHQ/BanquetInterior_1') self.geom.reparentTo(self) self.ceo = BossCog() dna = SuitDNA() dna.newBossCog('c') self.ceo.setDNA(dna) self.ceo.reparentTo(self) self.ceo.setPosHpr(0, 236.5, 0, 180, 0, 0) self.ceo.loop('Bb_neutral') def delete(self): if self.geom: self.geom.removeNode() self.geom = None if self.ceo: self.ceo.delete() self.ceo = None ThreeDScene.delete(self) return class HeadHunterScene(ThreeDScene): CameraPos = [(-22, -12.5, 7, 92, -6, 0)] def __init__(self, effects = []): ThreeDScene.__init__(self, 'HeadHunterScene', effects) self.geom = loader.loadModel('phase_12/models/bossbotHQ/BossbotEntranceRoom') self.geom.reparentTo(self) self.cog = Suit() dna = SuitDNA() dna.newSuit('hh') self.cog.setDNA(dna) self.cog.reparentTo(self) self.cog.setPosHpr(-32.5, -12.5, 0.02, 270, 0, 0) self.cog.nametag3d.removeNode() self.cog.nametag.destroy() self.cog.loop('neutral') def delete(self): if self.geom: self.geom.removeNode() self.geom = None if self.cog: self.cog.delete() self.cog = None ThreeDScene.delete(self) return class ScientistScene(ThreeDScene): CameraPos = [(-47.5, 0.5, 3.415, 90, 0, 0)] ToonPos = {2018: (-59, -1.5, 0.02, 270, 0, 0), 2019: (-59, 0.5, 0.02, 270, 0, 0), 2020: (-59, 2.5, 0.02, 270, 0, 0)} RandomEmotes = ['wave', 'angry', 'applause', 'cringe', 'confused', 'slip-forward', 'slip-backward', 'resistance-salute', 'surprise', 'cry', 'furious', 'laugh', 'idea', 'taunt', 'rage'] def __init__(self, effects = []): ThreeDScene.__init__(self, 'ScientistScene', effects) self.geom = loader.loadModel('phase_3.5/models/modules/tt_m_ara_int_toonhall') self.geom.reparentTo(self) self.taskStarted = False self.npcs = [] for id, posHpr in self.ToonPos.iteritems(): npc = NPCToons.createLocalNPC(id) npc.reparentTo(self.geom) npc.setPosHpr(*posHpr) npc.nametag3d.removeNode() npc.nametag.destroy() self.npcs.append(npc) def delete(self): if self.geom: self.geom.removeNode() self.geom = None for npc in self.npcs: taskMgr.remove(npc.uniqueName('randomEmote')) npc.delete() self.npcs = [] self.taskStarted = False ThreeDScene.delete(self) return def startTask(self): if self.taskStarted: return for i, npc in enumerate(self.npcs): taskMgr.doMethodLater(0.25 * i, lambda task, npc = npc: self.doRandomEmote(npc, task), npc.uniqueName('randomEmote')) self.taskStarted = True def <|fim_middle|>(self): if not self.taskStarted: return for npc in self.npcs: taskMgr.remove(npc.uniqueName('randomEmote')) self.taskStarted = False def doRandomEmote(self, npc, task): Emote.globalEmote.doEmote(npc, TTEmote.Emotes.index(random.choice(self.RandomEmotes)), 0) task.delayTime = npc.emoteTrack.getDuration() + 1.0 return task.again<|fim▁end|>
stopTask
<|file_name|>TutorialTVScenes.py<|end_file_name|><|fim▁begin|># Fuck you Disyer. Stealing my fucking paypal. GET FUCKED: toontown.tutorial.TutorialTVScenes from panda3d.core import Camera from direct.task.Task import Task from otp.avatar import Emote from toontown.television.TVScenes import * from toontown.television.TVEffects import * from toontown.suit.Suit import Suit from toontown.suit.BossCog import BossCog from toontown.suit.SuitDNA import SuitDNA from toontown.toon import NPCToons, TTEmote import random class CEOScene(ThreeDScene): CameraPos = [(0, 203.5, 23.5, 0, 350, 0)] def __init__(self, effects = []): ThreeDScene.__init__(self, 'CEOScene', effects) self.geom = loader.loadModel('phase_12/models/bossbotHQ/BanquetInterior_1') self.geom.reparentTo(self) self.ceo = BossCog() dna = SuitDNA() dna.newBossCog('c') self.ceo.setDNA(dna) self.ceo.reparentTo(self) self.ceo.setPosHpr(0, 236.5, 0, 180, 0, 0) self.ceo.loop('Bb_neutral') def delete(self): if self.geom: self.geom.removeNode() self.geom = None if self.ceo: self.ceo.delete() self.ceo = None ThreeDScene.delete(self) return class HeadHunterScene(ThreeDScene): CameraPos = [(-22, -12.5, 7, 92, -6, 0)] def __init__(self, effects = []): ThreeDScene.__init__(self, 'HeadHunterScene', effects) self.geom = loader.loadModel('phase_12/models/bossbotHQ/BossbotEntranceRoom') self.geom.reparentTo(self) self.cog = Suit() dna = SuitDNA() dna.newSuit('hh') self.cog.setDNA(dna) self.cog.reparentTo(self) self.cog.setPosHpr(-32.5, -12.5, 0.02, 270, 0, 0) self.cog.nametag3d.removeNode() self.cog.nametag.destroy() self.cog.loop('neutral') def delete(self): if self.geom: self.geom.removeNode() self.geom = None if self.cog: self.cog.delete() self.cog = None ThreeDScene.delete(self) return class ScientistScene(ThreeDScene): CameraPos = [(-47.5, 0.5, 3.415, 90, 0, 0)] ToonPos = {2018: (-59, -1.5, 0.02, 270, 0, 0), 2019: (-59, 0.5, 0.02, 270, 0, 0), 2020: (-59, 2.5, 0.02, 270, 0, 0)} RandomEmotes = ['wave', 'angry', 'applause', 'cringe', 'confused', 'slip-forward', 'slip-backward', 'resistance-salute', 'surprise', 'cry', 'furious', 'laugh', 'idea', 'taunt', 'rage'] def __init__(self, effects = []): ThreeDScene.__init__(self, 'ScientistScene', effects) self.geom = loader.loadModel('phase_3.5/models/modules/tt_m_ara_int_toonhall') self.geom.reparentTo(self) self.taskStarted = False self.npcs = [] for id, posHpr in self.ToonPos.iteritems(): npc = NPCToons.createLocalNPC(id) npc.reparentTo(self.geom) npc.setPosHpr(*posHpr) npc.nametag3d.removeNode() npc.nametag.destroy() self.npcs.append(npc) def delete(self): if self.geom: self.geom.removeNode() self.geom = None for npc in self.npcs: taskMgr.remove(npc.uniqueName('randomEmote')) npc.delete() self.npcs = [] self.taskStarted = False ThreeDScene.delete(self) return def startTask(self): if self.taskStarted: return for i, npc in enumerate(self.npcs): taskMgr.doMethodLater(0.25 * i, lambda task, npc = npc: self.doRandomEmote(npc, task), npc.uniqueName('randomEmote')) self.taskStarted = True def stopTask(self): if not self.taskStarted: return for npc in self.npcs: taskMgr.remove(npc.uniqueName('randomEmote')) self.taskStarted = False def <|fim_middle|>(self, npc, task): Emote.globalEmote.doEmote(npc, TTEmote.Emotes.index(random.choice(self.RandomEmotes)), 0) task.delayTime = npc.emoteTrack.getDuration() + 1.0 return task.again<|fim▁end|>
doRandomEmote
<|file_name|>app_config.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python """ Project-wide application configuration. DO NOT STORE SECRETS, PASSWORDS, ETC. IN THIS FILE. They will be exposed to users. Use environment variables instead. See get_secrets() below for a fast way to access them. """ import os """ NAMES """ # Project name used for display PROJECT_NAME = 'quotable' # Project name in urls # Use dashes, not underscores! PROJECT_SLUG = 'quotable' # The name of the repository containing the source REPOSITORY_NAME = 'quotable' REPOSITORY_URL = '[email protected]:nprapps/%s.git' % REPOSITORY_NAME<|fim▁hole|> """ DEPLOYMENT """ FILE_SERVER = 'tools.apps.npr.org' S3_BUCKET = 'tools.apps.npr.org' ASSETS_S3_BUCKET = 'assets.apps.npr.org' # These variables will be set at runtime. See configure_targets() below DEBUG = True """ COPY EDITING """ COPY_GOOGLE_DOC_KEY = '0AlXMOHKxzQVRdHZuX1UycXplRlBfLVB0UVNldHJYZmc' """ SHARING """ PROJECT_DESCRIPTION = 'An opinionated project template for (mostly) server-less apps.' SHARE_URL = 'http://%s/%s/' % (S3_BUCKET, PROJECT_SLUG) TWITTER = { 'TEXT': PROJECT_NAME, 'URL': SHARE_URL, # Will be resized to 120x120, can't be larger than 1MB 'IMAGE_URL': '' } FACEBOOK = { 'TITLE': PROJECT_NAME, 'URL': SHARE_URL, 'DESCRIPTION': PROJECT_DESCRIPTION, # Should be square. No documented restrictions on size 'IMAGE_URL': TWITTER['IMAGE_URL'], 'APP_ID': '138837436154588' } GOOGLE = { # Thumbnail image for Google News / Search. # No documented restrictions on resolution or size 'IMAGE_URL': TWITTER['IMAGE_URL'] } NPR_DFP = { 'STORY_ID': '203618536', 'TARGET': 'News_NPR_News_Investigations', 'ENVIRONMENT': 'NPRTEST', 'TESTSERVER': 'true' } """ SERVICES """ GOOGLE_ANALYTICS_ID = 'UA-5828686-4'<|fim▁end|>
REPOSITORY_ALT_URL = None # '[email protected]:nprapps/%s.git' % REPOSITORY_NAME' # The name to be used in paths on the server PROJECT_FILENAME = 'quotable'
<|file_name|>logging.py<|end_file_name|><|fim▁begin|>import logging.handlers import os _pabotlog = logging.getLogger('PABot') _pabotlog.setLevel(logging.DEBUG) _logPath = os.path.abspath("./logging/pabot.log") _formatter = logging.Formatter('%(asctime)s - %(levelname)s - %(name)s - %(message)s') _consoleStreamHandler = logging.StreamHandler() _consoleStreamHandler.setLevel(logging.DEBUG) _consoleStreamHandler.setFormatter(_formatter) _symLogRotFileHandler = logging.handlers.RotatingFileHandler(_logPath, maxBytes=2000000, backupCount=5) _symLogRotFileHandler.setLevel(logging.DEBUG) _symLogRotFileHandler.setFormatter(_formatter) _pabotlog.addHandler(_consoleStreamHandler) _pabotlog.addHandler(_symLogRotFileHandler) <|fim▁hole|>def LogPABotMessage(message): _pabotlog.info(message) def LogPABotError(message): _pabotlog.error(message)<|fim▁end|>
<|file_name|>logging.py<|end_file_name|><|fim▁begin|>import logging.handlers import os _pabotlog = logging.getLogger('PABot') _pabotlog.setLevel(logging.DEBUG) _logPath = os.path.abspath("./logging/pabot.log") _formatter = logging.Formatter('%(asctime)s - %(levelname)s - %(name)s - %(message)s') _consoleStreamHandler = logging.StreamHandler() _consoleStreamHandler.setLevel(logging.DEBUG) _consoleStreamHandler.setFormatter(_formatter) _symLogRotFileHandler = logging.handlers.RotatingFileHandler(_logPath, maxBytes=2000000, backupCount=5) _symLogRotFileHandler.setLevel(logging.DEBUG) _symLogRotFileHandler.setFormatter(_formatter) _pabotlog.addHandler(_consoleStreamHandler) _pabotlog.addHandler(_symLogRotFileHandler) def LogPABotMessage(message): <|fim_middle|> def LogPABotError(message): _pabotlog.error(message) <|fim▁end|>
_pabotlog.info(message)
<|file_name|>logging.py<|end_file_name|><|fim▁begin|>import logging.handlers import os _pabotlog = logging.getLogger('PABot') _pabotlog.setLevel(logging.DEBUG) _logPath = os.path.abspath("./logging/pabot.log") _formatter = logging.Formatter('%(asctime)s - %(levelname)s - %(name)s - %(message)s') _consoleStreamHandler = logging.StreamHandler() _consoleStreamHandler.setLevel(logging.DEBUG) _consoleStreamHandler.setFormatter(_formatter) _symLogRotFileHandler = logging.handlers.RotatingFileHandler(_logPath, maxBytes=2000000, backupCount=5) _symLogRotFileHandler.setLevel(logging.DEBUG) _symLogRotFileHandler.setFormatter(_formatter) _pabotlog.addHandler(_consoleStreamHandler) _pabotlog.addHandler(_symLogRotFileHandler) def LogPABotMessage(message): _pabotlog.info(message) def LogPABotError(message): <|fim_middle|> <|fim▁end|>
_pabotlog.error(message)
<|file_name|>logging.py<|end_file_name|><|fim▁begin|>import logging.handlers import os _pabotlog = logging.getLogger('PABot') _pabotlog.setLevel(logging.DEBUG) _logPath = os.path.abspath("./logging/pabot.log") _formatter = logging.Formatter('%(asctime)s - %(levelname)s - %(name)s - %(message)s') _consoleStreamHandler = logging.StreamHandler() _consoleStreamHandler.setLevel(logging.DEBUG) _consoleStreamHandler.setFormatter(_formatter) _symLogRotFileHandler = logging.handlers.RotatingFileHandler(_logPath, maxBytes=2000000, backupCount=5) _symLogRotFileHandler.setLevel(logging.DEBUG) _symLogRotFileHandler.setFormatter(_formatter) _pabotlog.addHandler(_consoleStreamHandler) _pabotlog.addHandler(_symLogRotFileHandler) def <|fim_middle|>(message): _pabotlog.info(message) def LogPABotError(message): _pabotlog.error(message) <|fim▁end|>
LogPABotMessage
<|file_name|>logging.py<|end_file_name|><|fim▁begin|>import logging.handlers import os _pabotlog = logging.getLogger('PABot') _pabotlog.setLevel(logging.DEBUG) _logPath = os.path.abspath("./logging/pabot.log") _formatter = logging.Formatter('%(asctime)s - %(levelname)s - %(name)s - %(message)s') _consoleStreamHandler = logging.StreamHandler() _consoleStreamHandler.setLevel(logging.DEBUG) _consoleStreamHandler.setFormatter(_formatter) _symLogRotFileHandler = logging.handlers.RotatingFileHandler(_logPath, maxBytes=2000000, backupCount=5) _symLogRotFileHandler.setLevel(logging.DEBUG) _symLogRotFileHandler.setFormatter(_formatter) _pabotlog.addHandler(_consoleStreamHandler) _pabotlog.addHandler(_symLogRotFileHandler) def LogPABotMessage(message): _pabotlog.info(message) def <|fim_middle|>(message): _pabotlog.error(message) <|fim▁end|>
LogPABotError
<|file_name|>separator.py<|end_file_name|><|fim▁begin|>from __future__ import division from __future__ import print_function from __future__ import absolute_import <|fim▁hole|>class Separator(wx.StaticLine): def __init__(self, parent): wx.StaticLine.__init__(self, parent.get_container(), -1, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL) update_class(Separator)<|fim▁end|>
import wx from .common import update_class
<|file_name|>separator.py<|end_file_name|><|fim▁begin|>from __future__ import division from __future__ import print_function from __future__ import absolute_import import wx from .common import update_class class Separator(wx.StaticLine): <|fim_middle|> update_class(Separator) <|fim▁end|>
def __init__(self, parent): wx.StaticLine.__init__(self, parent.get_container(), -1, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL)
<|file_name|>separator.py<|end_file_name|><|fim▁begin|>from __future__ import division from __future__ import print_function from __future__ import absolute_import import wx from .common import update_class class Separator(wx.StaticLine): def __init__(self, parent): <|fim_middle|> update_class(Separator) <|fim▁end|>
wx.StaticLine.__init__(self, parent.get_container(), -1, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL)
<|file_name|>separator.py<|end_file_name|><|fim▁begin|>from __future__ import division from __future__ import print_function from __future__ import absolute_import import wx from .common import update_class class Separator(wx.StaticLine): def <|fim_middle|>(self, parent): wx.StaticLine.__init__(self, parent.get_container(), -1, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL) update_class(Separator) <|fim▁end|>
__init__
<|file_name|>database_type.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- ############################################################################## # # Infrastructure # Copyright (C) 2014 Ingenieria ADHOC # No email # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as # published by the Free Software Foundation, either version 3 of the # License, or (at your option) any later version. # # This program 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 Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # ############################################################################## import re from openerp import netsvc from openerp.osv import osv, fields class database_type(osv.osv): """""" _name = 'infrastructure.database_type' _description = 'database_type' _columns = { 'name': fields.char(string='Name', required=True), 'prefix': fields.char(string='Prefix', required=True, size=4), 'url_prefix': fields.char(string='URL Prefix'), 'automatic_drop': fields.boolean(string='Automatic Drop'), 'automatic_drop_days': fields.integer(string='Automatic Drop Days'), 'protect_db': fields.boolean(string='Protect DBs?'), 'color': fields.integer(string='Color'), 'automatic_deactivation': fields.boolean(string='Atumatic Deactivation?'), 'auto_deactivation_days': fields.integer(string='Automatic Drop Days'), 'url_example': fields.char(string='URL Example'), 'bd_name_example': fields.char(string='BD Name Example'), 'db_back_up_policy_ids': fields.many2many('infrastructure.db_back_up_policy', 'infrastructure_database_type_ids_db_back_up_policy_ids_rel', 'database_type_id', 'db_back_up_policy_id', string='Suggested Backup Policies'), } _defaults = { } _constraints = [ ] <|fim▁hole|> database_type() # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:<|fim▁end|>
<|file_name|>database_type.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- ############################################################################## # # Infrastructure # Copyright (C) 2014 Ingenieria ADHOC # No email # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as # published by the Free Software Foundation, either version 3 of the # License, or (at your option) any later version. # # This program 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 Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # ############################################################################## import re from openerp import netsvc from openerp.osv import osv, fields class database_type(osv.osv): <|fim_middle|> database_type() # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: <|fim▁end|>
"""""" _name = 'infrastructure.database_type' _description = 'database_type' _columns = { 'name': fields.char(string='Name', required=True), 'prefix': fields.char(string='Prefix', required=True, size=4), 'url_prefix': fields.char(string='URL Prefix'), 'automatic_drop': fields.boolean(string='Automatic Drop'), 'automatic_drop_days': fields.integer(string='Automatic Drop Days'), 'protect_db': fields.boolean(string='Protect DBs?'), 'color': fields.integer(string='Color'), 'automatic_deactivation': fields.boolean(string='Atumatic Deactivation?'), 'auto_deactivation_days': fields.integer(string='Automatic Drop Days'), 'url_example': fields.char(string='URL Example'), 'bd_name_example': fields.char(string='BD Name Example'), 'db_back_up_policy_ids': fields.many2many('infrastructure.db_back_up_policy', 'infrastructure_database_type_ids_db_back_up_policy_ids_rel', 'database_type_id', 'db_back_up_policy_id', string='Suggested Backup Policies'), } _defaults = { } _constraints = [ ]
<|file_name|>test_property_delete.py<|end_file_name|><|fim▁begin|>""" Unit tests to ensure that we can call reset_traits/delete on a property trait (regression tests for Github issue #67). """ from traits import _py2to3 from traits.api import Any, HasTraits, Int, Property, TraitError from traits.testing.unittest_tools import unittest class E(HasTraits): a = Property(Any) b = Property(Int) class TestPropertyDelete(unittest.TestCase): def test_property_delete(self): e = E() with self.assertRaises(TraitError): del e.a with self.assertRaises(TraitError): del e.b def test_property_reset_traits(self):<|fim▁hole|><|fim▁end|>
e = E() unresetable = e.reset_traits() _py2to3.assertCountEqual(self, unresetable, ['a', 'b'])
<|file_name|>test_property_delete.py<|end_file_name|><|fim▁begin|>""" Unit tests to ensure that we can call reset_traits/delete on a property trait (regression tests for Github issue #67). """ from traits import _py2to3 from traits.api import Any, HasTraits, Int, Property, TraitError from traits.testing.unittest_tools import unittest class E(HasTraits): <|fim_middle|> class TestPropertyDelete(unittest.TestCase): def test_property_delete(self): e = E() with self.assertRaises(TraitError): del e.a with self.assertRaises(TraitError): del e.b def test_property_reset_traits(self): e = E() unresetable = e.reset_traits() _py2to3.assertCountEqual(self, unresetable, ['a', 'b']) <|fim▁end|>
a = Property(Any) b = Property(Int)
<|file_name|>test_property_delete.py<|end_file_name|><|fim▁begin|>""" Unit tests to ensure that we can call reset_traits/delete on a property trait (regression tests for Github issue #67). """ from traits import _py2to3 from traits.api import Any, HasTraits, Int, Property, TraitError from traits.testing.unittest_tools import unittest class E(HasTraits): a = Property(Any) b = Property(Int) class TestPropertyDelete(unittest.TestCase): <|fim_middle|> <|fim▁end|>
def test_property_delete(self): e = E() with self.assertRaises(TraitError): del e.a with self.assertRaises(TraitError): del e.b def test_property_reset_traits(self): e = E() unresetable = e.reset_traits() _py2to3.assertCountEqual(self, unresetable, ['a', 'b'])
<|file_name|>test_property_delete.py<|end_file_name|><|fim▁begin|>""" Unit tests to ensure that we can call reset_traits/delete on a property trait (regression tests for Github issue #67). """ from traits import _py2to3 from traits.api import Any, HasTraits, Int, Property, TraitError from traits.testing.unittest_tools import unittest class E(HasTraits): a = Property(Any) b = Property(Int) class TestPropertyDelete(unittest.TestCase): def test_property_delete(self): <|fim_middle|> def test_property_reset_traits(self): e = E() unresetable = e.reset_traits() _py2to3.assertCountEqual(self, unresetable, ['a', 'b']) <|fim▁end|>
e = E() with self.assertRaises(TraitError): del e.a with self.assertRaises(TraitError): del e.b
<|file_name|>test_property_delete.py<|end_file_name|><|fim▁begin|>""" Unit tests to ensure that we can call reset_traits/delete on a property trait (regression tests for Github issue #67). """ from traits import _py2to3 from traits.api import Any, HasTraits, Int, Property, TraitError from traits.testing.unittest_tools import unittest class E(HasTraits): a = Property(Any) b = Property(Int) class TestPropertyDelete(unittest.TestCase): def test_property_delete(self): e = E() with self.assertRaises(TraitError): del e.a with self.assertRaises(TraitError): del e.b def test_property_reset_traits(self): <|fim_middle|> <|fim▁end|>
e = E() unresetable = e.reset_traits() _py2to3.assertCountEqual(self, unresetable, ['a', 'b'])
<|file_name|>test_property_delete.py<|end_file_name|><|fim▁begin|>""" Unit tests to ensure that we can call reset_traits/delete on a property trait (regression tests for Github issue #67). """ from traits import _py2to3 from traits.api import Any, HasTraits, Int, Property, TraitError from traits.testing.unittest_tools import unittest class E(HasTraits): a = Property(Any) b = Property(Int) class TestPropertyDelete(unittest.TestCase): def <|fim_middle|>(self): e = E() with self.assertRaises(TraitError): del e.a with self.assertRaises(TraitError): del e.b def test_property_reset_traits(self): e = E() unresetable = e.reset_traits() _py2to3.assertCountEqual(self, unresetable, ['a', 'b']) <|fim▁end|>
test_property_delete
<|file_name|>test_property_delete.py<|end_file_name|><|fim▁begin|>""" Unit tests to ensure that we can call reset_traits/delete on a property trait (regression tests for Github issue #67). """ from traits import _py2to3 from traits.api import Any, HasTraits, Int, Property, TraitError from traits.testing.unittest_tools import unittest class E(HasTraits): a = Property(Any) b = Property(Int) class TestPropertyDelete(unittest.TestCase): def test_property_delete(self): e = E() with self.assertRaises(TraitError): del e.a with self.assertRaises(TraitError): del e.b def <|fim_middle|>(self): e = E() unresetable = e.reset_traits() _py2to3.assertCountEqual(self, unresetable, ['a', 'b']) <|fim▁end|>
test_property_reset_traits
<|file_name|>shuffelz.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python '''# shufflez.py ''' # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # * Neither the name of the <organization> nor the # names of its contributors may be used to endorse or promote products # derived from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE # DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY # DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. __author__ = ["A'mmer Almadani:Mad_Dev", "sysbase.org"] __email__ = ["[email protected]", "[email protected]"] import random import urllib2 from search import GoogleSearch, SearchError import time from multiprocessing import Process from threading import Timer class shufflez: def __init__(self): self.word_list = 'lists/wordlist.txt' self.websites = 'lists/websites.txt' self.user_agent = 'lists/user_agent.txt' def together(self, *functions): process = [] for function in functions: s = Process(target=function) s.start() process.append(s) for s in process: s.join() def randomize(self, r, typ): '''Return Random List r (range): int typ : word | site | user-agent ''' lst = [] if typ == 'word': list_to_parse = self.word_list elif typ == 'site': list_to_parse = self.websites elif typ == 'user-agent': list_to_parse = self.user_agent a = open(list_to_parse, 'r') for i in a.readlines(): lst.append(i) random.shuffle(lst) if typ == 'site': return map(lambda x:x if 'http://' in x else 'http://' +x, lst)[0:int(r)] else: return lst[0:int(r)] def append_to_list(self, typ, lst): if typ == 'word': l = self.word_list elif typ == 'link': l = self.websites li = open(l, 'a') for i in lst: li.write(i+'\n') li.close() def open_url(self, url, user_agent): try: header = { 'User-Agent' : str(user_agent) } req = urllib2.Request(url, headers=header) response = urllib2.urlopen(req) print 'STATUS', response.getcode() except: pass def google(self, term): links_from_google = [] words_from_google = [] try: gs = GoogleSearch(term) gs.results_per_page = 10 results = gs.get_results() for res in results: words_from_google.append(res.title.encode('utf8')) print '\033[92mGot new words from Google...appending to list\n\033[0m' self.append_to_list('word', words_from_google) links_from_google.append(res.url.encode('utf8')) print '\033[92mGot new link from Google...appending to list\n\033[0m' self.append_to_list('link', links_from_google)<|fim▁hole|> print "Search failed: %s" % e mask = shufflez() def random_websites(): count = random.randint(1,15) for i, e, in zip(mask.randomize(10, 'site'), mask.randomize(10, 'user-agent')): if count == random.randint(1,15): break else: sleep_time = str(random.randint(1,5)) +'.'+ str(random.randint(1,9)) print 'VISITING', '\033[92m', i , '\033[0m', 'USING', '\033[94m', e, '\033[0m', 'SLEEPING FOR', '\033[95m', sleep_time, 'SECONDS', '\033[0m' time.sleep(float(sleep_time)) mask.open_url(i, e) print '\n' def random_google(): count = random.randint(1,15) for i in mask.randomize(10, 'word'): if count == random.randint(1,15): break else: sleep_time = str(random.randint(1,5)) +'.'+ str(random.randint(1,9)) print 'SEARCHING FOR', '\033[92m', i ,'\033[0m', 'SLEEPING FOR', '\033[95m', sleep_time, 'SECONDS', '\033[0m', '\n' time.sleep(float(sleep_time)) mask.google(i) #while True: # try: # mask.together(random_google(), random_websites()) # except KeyboardInterrupt: # print 'Exit' # break<|fim▁end|>
except SearchError, e:
<|file_name|>shuffelz.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python '''# shufflez.py ''' # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # * Neither the name of the <organization> nor the # names of its contributors may be used to endorse or promote products # derived from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE # DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY # DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. __author__ = ["A'mmer Almadani:Mad_Dev", "sysbase.org"] __email__ = ["[email protected]", "[email protected]"] import random import urllib2 from search import GoogleSearch, SearchError import time from multiprocessing import Process from threading import Timer class shufflez: <|fim_middle|> mask = shufflez() def random_websites(): count = random.randint(1,15) for i, e, in zip(mask.randomize(10, 'site'), mask.randomize(10, 'user-agent')): if count == random.randint(1,15): break else: sleep_time = str(random.randint(1,5)) +'.'+ str(random.randint(1,9)) print 'VISITING', '\033[92m', i , '\033[0m', 'USING', '\033[94m', e, '\033[0m', 'SLEEPING FOR', '\033[95m', sleep_time, 'SECONDS', '\033[0m' time.sleep(float(sleep_time)) mask.open_url(i, e) print '\n' def random_google(): count = random.randint(1,15) for i in mask.randomize(10, 'word'): if count == random.randint(1,15): break else: sleep_time = str(random.randint(1,5)) +'.'+ str(random.randint(1,9)) print 'SEARCHING FOR', '\033[92m', i ,'\033[0m', 'SLEEPING FOR', '\033[95m', sleep_time, 'SECONDS', '\033[0m', '\n' time.sleep(float(sleep_time)) mask.google(i) #while True: # try: # mask.together(random_google(), random_websites()) # except KeyboardInterrupt: # print 'Exit' # break<|fim▁end|>
def __init__(self): self.word_list = 'lists/wordlist.txt' self.websites = 'lists/websites.txt' self.user_agent = 'lists/user_agent.txt' def together(self, *functions): process = [] for function in functions: s = Process(target=function) s.start() process.append(s) for s in process: s.join() def randomize(self, r, typ): '''Return Random List r (range): int typ : word | site | user-agent ''' lst = [] if typ == 'word': list_to_parse = self.word_list elif typ == 'site': list_to_parse = self.websites elif typ == 'user-agent': list_to_parse = self.user_agent a = open(list_to_parse, 'r') for i in a.readlines(): lst.append(i) random.shuffle(lst) if typ == 'site': return map(lambda x:x if 'http://' in x else 'http://' +x, lst)[0:int(r)] else: return lst[0:int(r)] def append_to_list(self, typ, lst): if typ == 'word': l = self.word_list elif typ == 'link': l = self.websites li = open(l, 'a') for i in lst: li.write(i+'\n') li.close() def open_url(self, url, user_agent): try: header = { 'User-Agent' : str(user_agent) } req = urllib2.Request(url, headers=header) response = urllib2.urlopen(req) print 'STATUS', response.getcode() except: pass def google(self, term): links_from_google = [] words_from_google = [] try: gs = GoogleSearch(term) gs.results_per_page = 10 results = gs.get_results() for res in results: words_from_google.append(res.title.encode('utf8')) print '\033[92mGot new words from Google...appending to list\n\033[0m' self.append_to_list('word', words_from_google) links_from_google.append(res.url.encode('utf8')) print '\033[92mGot new link from Google...appending to list\n\033[0m' self.append_to_list('link', links_from_google) except SearchError, e: print "Search failed: %s" % e
<|file_name|>shuffelz.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python '''# shufflez.py ''' # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # * Neither the name of the <organization> nor the # names of its contributors may be used to endorse or promote products # derived from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE # DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY # DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. __author__ = ["A'mmer Almadani:Mad_Dev", "sysbase.org"] __email__ = ["[email protected]", "[email protected]"] import random import urllib2 from search import GoogleSearch, SearchError import time from multiprocessing import Process from threading import Timer class shufflez: def __init__(self): <|fim_middle|> def together(self, *functions): process = [] for function in functions: s = Process(target=function) s.start() process.append(s) for s in process: s.join() def randomize(self, r, typ): '''Return Random List r (range): int typ : word | site | user-agent ''' lst = [] if typ == 'word': list_to_parse = self.word_list elif typ == 'site': list_to_parse = self.websites elif typ == 'user-agent': list_to_parse = self.user_agent a = open(list_to_parse, 'r') for i in a.readlines(): lst.append(i) random.shuffle(lst) if typ == 'site': return map(lambda x:x if 'http://' in x else 'http://' +x, lst)[0:int(r)] else: return lst[0:int(r)] def append_to_list(self, typ, lst): if typ == 'word': l = self.word_list elif typ == 'link': l = self.websites li = open(l, 'a') for i in lst: li.write(i+'\n') li.close() def open_url(self, url, user_agent): try: header = { 'User-Agent' : str(user_agent) } req = urllib2.Request(url, headers=header) response = urllib2.urlopen(req) print 'STATUS', response.getcode() except: pass def google(self, term): links_from_google = [] words_from_google = [] try: gs = GoogleSearch(term) gs.results_per_page = 10 results = gs.get_results() for res in results: words_from_google.append(res.title.encode('utf8')) print '\033[92mGot new words from Google...appending to list\n\033[0m' self.append_to_list('word', words_from_google) links_from_google.append(res.url.encode('utf8')) print '\033[92mGot new link from Google...appending to list\n\033[0m' self.append_to_list('link', links_from_google) except SearchError, e: print "Search failed: %s" % e mask = shufflez() def random_websites(): count = random.randint(1,15) for i, e, in zip(mask.randomize(10, 'site'), mask.randomize(10, 'user-agent')): if count == random.randint(1,15): break else: sleep_time = str(random.randint(1,5)) +'.'+ str(random.randint(1,9)) print 'VISITING', '\033[92m', i , '\033[0m', 'USING', '\033[94m', e, '\033[0m', 'SLEEPING FOR', '\033[95m', sleep_time, 'SECONDS', '\033[0m' time.sleep(float(sleep_time)) mask.open_url(i, e) print '\n' def random_google(): count = random.randint(1,15) for i in mask.randomize(10, 'word'): if count == random.randint(1,15): break else: sleep_time = str(random.randint(1,5)) +'.'+ str(random.randint(1,9)) print 'SEARCHING FOR', '\033[92m', i ,'\033[0m', 'SLEEPING FOR', '\033[95m', sleep_time, 'SECONDS', '\033[0m', '\n' time.sleep(float(sleep_time)) mask.google(i) #while True: # try: # mask.together(random_google(), random_websites()) # except KeyboardInterrupt: # print 'Exit' # break<|fim▁end|>
self.word_list = 'lists/wordlist.txt' self.websites = 'lists/websites.txt' self.user_agent = 'lists/user_agent.txt'
<|file_name|>shuffelz.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python '''# shufflez.py ''' # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # * Neither the name of the <organization> nor the # names of its contributors may be used to endorse or promote products # derived from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE # DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY # DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. __author__ = ["A'mmer Almadani:Mad_Dev", "sysbase.org"] __email__ = ["[email protected]", "[email protected]"] import random import urllib2 from search import GoogleSearch, SearchError import time from multiprocessing import Process from threading import Timer class shufflez: def __init__(self): self.word_list = 'lists/wordlist.txt' self.websites = 'lists/websites.txt' self.user_agent = 'lists/user_agent.txt' def together(self, *functions): <|fim_middle|> def randomize(self, r, typ): '''Return Random List r (range): int typ : word | site | user-agent ''' lst = [] if typ == 'word': list_to_parse = self.word_list elif typ == 'site': list_to_parse = self.websites elif typ == 'user-agent': list_to_parse = self.user_agent a = open(list_to_parse, 'r') for i in a.readlines(): lst.append(i) random.shuffle(lst) if typ == 'site': return map(lambda x:x if 'http://' in x else 'http://' +x, lst)[0:int(r)] else: return lst[0:int(r)] def append_to_list(self, typ, lst): if typ == 'word': l = self.word_list elif typ == 'link': l = self.websites li = open(l, 'a') for i in lst: li.write(i+'\n') li.close() def open_url(self, url, user_agent): try: header = { 'User-Agent' : str(user_agent) } req = urllib2.Request(url, headers=header) response = urllib2.urlopen(req) print 'STATUS', response.getcode() except: pass def google(self, term): links_from_google = [] words_from_google = [] try: gs = GoogleSearch(term) gs.results_per_page = 10 results = gs.get_results() for res in results: words_from_google.append(res.title.encode('utf8')) print '\033[92mGot new words from Google...appending to list\n\033[0m' self.append_to_list('word', words_from_google) links_from_google.append(res.url.encode('utf8')) print '\033[92mGot new link from Google...appending to list\n\033[0m' self.append_to_list('link', links_from_google) except SearchError, e: print "Search failed: %s" % e mask = shufflez() def random_websites(): count = random.randint(1,15) for i, e, in zip(mask.randomize(10, 'site'), mask.randomize(10, 'user-agent')): if count == random.randint(1,15): break else: sleep_time = str(random.randint(1,5)) +'.'+ str(random.randint(1,9)) print 'VISITING', '\033[92m', i , '\033[0m', 'USING', '\033[94m', e, '\033[0m', 'SLEEPING FOR', '\033[95m', sleep_time, 'SECONDS', '\033[0m' time.sleep(float(sleep_time)) mask.open_url(i, e) print '\n' def random_google(): count = random.randint(1,15) for i in mask.randomize(10, 'word'): if count == random.randint(1,15): break else: sleep_time = str(random.randint(1,5)) +'.'+ str(random.randint(1,9)) print 'SEARCHING FOR', '\033[92m', i ,'\033[0m', 'SLEEPING FOR', '\033[95m', sleep_time, 'SECONDS', '\033[0m', '\n' time.sleep(float(sleep_time)) mask.google(i) #while True: # try: # mask.together(random_google(), random_websites()) # except KeyboardInterrupt: # print 'Exit' # break<|fim▁end|>
process = [] for function in functions: s = Process(target=function) s.start() process.append(s) for s in process: s.join()
<|file_name|>shuffelz.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python '''# shufflez.py ''' # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # * Neither the name of the <organization> nor the # names of its contributors may be used to endorse or promote products # derived from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE # DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY # DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. __author__ = ["A'mmer Almadani:Mad_Dev", "sysbase.org"] __email__ = ["[email protected]", "[email protected]"] import random import urllib2 from search import GoogleSearch, SearchError import time from multiprocessing import Process from threading import Timer class shufflez: def __init__(self): self.word_list = 'lists/wordlist.txt' self.websites = 'lists/websites.txt' self.user_agent = 'lists/user_agent.txt' def together(self, *functions): process = [] for function in functions: s = Process(target=function) s.start() process.append(s) for s in process: s.join() def randomize(self, r, typ): <|fim_middle|> def append_to_list(self, typ, lst): if typ == 'word': l = self.word_list elif typ == 'link': l = self.websites li = open(l, 'a') for i in lst: li.write(i+'\n') li.close() def open_url(self, url, user_agent): try: header = { 'User-Agent' : str(user_agent) } req = urllib2.Request(url, headers=header) response = urllib2.urlopen(req) print 'STATUS', response.getcode() except: pass def google(self, term): links_from_google = [] words_from_google = [] try: gs = GoogleSearch(term) gs.results_per_page = 10 results = gs.get_results() for res in results: words_from_google.append(res.title.encode('utf8')) print '\033[92mGot new words from Google...appending to list\n\033[0m' self.append_to_list('word', words_from_google) links_from_google.append(res.url.encode('utf8')) print '\033[92mGot new link from Google...appending to list\n\033[0m' self.append_to_list('link', links_from_google) except SearchError, e: print "Search failed: %s" % e mask = shufflez() def random_websites(): count = random.randint(1,15) for i, e, in zip(mask.randomize(10, 'site'), mask.randomize(10, 'user-agent')): if count == random.randint(1,15): break else: sleep_time = str(random.randint(1,5)) +'.'+ str(random.randint(1,9)) print 'VISITING', '\033[92m', i , '\033[0m', 'USING', '\033[94m', e, '\033[0m', 'SLEEPING FOR', '\033[95m', sleep_time, 'SECONDS', '\033[0m' time.sleep(float(sleep_time)) mask.open_url(i, e) print '\n' def random_google(): count = random.randint(1,15) for i in mask.randomize(10, 'word'): if count == random.randint(1,15): break else: sleep_time = str(random.randint(1,5)) +'.'+ str(random.randint(1,9)) print 'SEARCHING FOR', '\033[92m', i ,'\033[0m', 'SLEEPING FOR', '\033[95m', sleep_time, 'SECONDS', '\033[0m', '\n' time.sleep(float(sleep_time)) mask.google(i) #while True: # try: # mask.together(random_google(), random_websites()) # except KeyboardInterrupt: # print 'Exit' # break<|fim▁end|>
'''Return Random List r (range): int typ : word | site | user-agent ''' lst = [] if typ == 'word': list_to_parse = self.word_list elif typ == 'site': list_to_parse = self.websites elif typ == 'user-agent': list_to_parse = self.user_agent a = open(list_to_parse, 'r') for i in a.readlines(): lst.append(i) random.shuffle(lst) if typ == 'site': return map(lambda x:x if 'http://' in x else 'http://' +x, lst)[0:int(r)] else: return lst[0:int(r)]
<|file_name|>shuffelz.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python '''# shufflez.py ''' # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # * Neither the name of the <organization> nor the # names of its contributors may be used to endorse or promote products # derived from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE # DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY # DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. __author__ = ["A'mmer Almadani:Mad_Dev", "sysbase.org"] __email__ = ["[email protected]", "[email protected]"] import random import urllib2 from search import GoogleSearch, SearchError import time from multiprocessing import Process from threading import Timer class shufflez: def __init__(self): self.word_list = 'lists/wordlist.txt' self.websites = 'lists/websites.txt' self.user_agent = 'lists/user_agent.txt' def together(self, *functions): process = [] for function in functions: s = Process(target=function) s.start() process.append(s) for s in process: s.join() def randomize(self, r, typ): '''Return Random List r (range): int typ : word | site | user-agent ''' lst = [] if typ == 'word': list_to_parse = self.word_list elif typ == 'site': list_to_parse = self.websites elif typ == 'user-agent': list_to_parse = self.user_agent a = open(list_to_parse, 'r') for i in a.readlines(): lst.append(i) random.shuffle(lst) if typ == 'site': return map(lambda x:x if 'http://' in x else 'http://' +x, lst)[0:int(r)] else: return lst[0:int(r)] def append_to_list(self, typ, lst): <|fim_middle|> def open_url(self, url, user_agent): try: header = { 'User-Agent' : str(user_agent) } req = urllib2.Request(url, headers=header) response = urllib2.urlopen(req) print 'STATUS', response.getcode() except: pass def google(self, term): links_from_google = [] words_from_google = [] try: gs = GoogleSearch(term) gs.results_per_page = 10 results = gs.get_results() for res in results: words_from_google.append(res.title.encode('utf8')) print '\033[92mGot new words from Google...appending to list\n\033[0m' self.append_to_list('word', words_from_google) links_from_google.append(res.url.encode('utf8')) print '\033[92mGot new link from Google...appending to list\n\033[0m' self.append_to_list('link', links_from_google) except SearchError, e: print "Search failed: %s" % e mask = shufflez() def random_websites(): count = random.randint(1,15) for i, e, in zip(mask.randomize(10, 'site'), mask.randomize(10, 'user-agent')): if count == random.randint(1,15): break else: sleep_time = str(random.randint(1,5)) +'.'+ str(random.randint(1,9)) print 'VISITING', '\033[92m', i , '\033[0m', 'USING', '\033[94m', e, '\033[0m', 'SLEEPING FOR', '\033[95m', sleep_time, 'SECONDS', '\033[0m' time.sleep(float(sleep_time)) mask.open_url(i, e) print '\n' def random_google(): count = random.randint(1,15) for i in mask.randomize(10, 'word'): if count == random.randint(1,15): break else: sleep_time = str(random.randint(1,5)) +'.'+ str(random.randint(1,9)) print 'SEARCHING FOR', '\033[92m', i ,'\033[0m', 'SLEEPING FOR', '\033[95m', sleep_time, 'SECONDS', '\033[0m', '\n' time.sleep(float(sleep_time)) mask.google(i) #while True: # try: # mask.together(random_google(), random_websites()) # except KeyboardInterrupt: # print 'Exit' # break<|fim▁end|>
if typ == 'word': l = self.word_list elif typ == 'link': l = self.websites li = open(l, 'a') for i in lst: li.write(i+'\n') li.close()
<|file_name|>shuffelz.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python '''# shufflez.py ''' # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # * Neither the name of the <organization> nor the # names of its contributors may be used to endorse or promote products # derived from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE # DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY # DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. __author__ = ["A'mmer Almadani:Mad_Dev", "sysbase.org"] __email__ = ["[email protected]", "[email protected]"] import random import urllib2 from search import GoogleSearch, SearchError import time from multiprocessing import Process from threading import Timer class shufflez: def __init__(self): self.word_list = 'lists/wordlist.txt' self.websites = 'lists/websites.txt' self.user_agent = 'lists/user_agent.txt' def together(self, *functions): process = [] for function in functions: s = Process(target=function) s.start() process.append(s) for s in process: s.join() def randomize(self, r, typ): '''Return Random List r (range): int typ : word | site | user-agent ''' lst = [] if typ == 'word': list_to_parse = self.word_list elif typ == 'site': list_to_parse = self.websites elif typ == 'user-agent': list_to_parse = self.user_agent a = open(list_to_parse, 'r') for i in a.readlines(): lst.append(i) random.shuffle(lst) if typ == 'site': return map(lambda x:x if 'http://' in x else 'http://' +x, lst)[0:int(r)] else: return lst[0:int(r)] def append_to_list(self, typ, lst): if typ == 'word': l = self.word_list elif typ == 'link': l = self.websites li = open(l, 'a') for i in lst: li.write(i+'\n') li.close() def open_url(self, url, user_agent): <|fim_middle|> def google(self, term): links_from_google = [] words_from_google = [] try: gs = GoogleSearch(term) gs.results_per_page = 10 results = gs.get_results() for res in results: words_from_google.append(res.title.encode('utf8')) print '\033[92mGot new words from Google...appending to list\n\033[0m' self.append_to_list('word', words_from_google) links_from_google.append(res.url.encode('utf8')) print '\033[92mGot new link from Google...appending to list\n\033[0m' self.append_to_list('link', links_from_google) except SearchError, e: print "Search failed: %s" % e mask = shufflez() def random_websites(): count = random.randint(1,15) for i, e, in zip(mask.randomize(10, 'site'), mask.randomize(10, 'user-agent')): if count == random.randint(1,15): break else: sleep_time = str(random.randint(1,5)) +'.'+ str(random.randint(1,9)) print 'VISITING', '\033[92m', i , '\033[0m', 'USING', '\033[94m', e, '\033[0m', 'SLEEPING FOR', '\033[95m', sleep_time, 'SECONDS', '\033[0m' time.sleep(float(sleep_time)) mask.open_url(i, e) print '\n' def random_google(): count = random.randint(1,15) for i in mask.randomize(10, 'word'): if count == random.randint(1,15): break else: sleep_time = str(random.randint(1,5)) +'.'+ str(random.randint(1,9)) print 'SEARCHING FOR', '\033[92m', i ,'\033[0m', 'SLEEPING FOR', '\033[95m', sleep_time, 'SECONDS', '\033[0m', '\n' time.sleep(float(sleep_time)) mask.google(i) #while True: # try: # mask.together(random_google(), random_websites()) # except KeyboardInterrupt: # print 'Exit' # break<|fim▁end|>
try: header = { 'User-Agent' : str(user_agent) } req = urllib2.Request(url, headers=header) response = urllib2.urlopen(req) print 'STATUS', response.getcode() except: pass
<|file_name|>shuffelz.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python '''# shufflez.py ''' # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # * Neither the name of the <organization> nor the # names of its contributors may be used to endorse or promote products # derived from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE # DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY # DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. __author__ = ["A'mmer Almadani:Mad_Dev", "sysbase.org"] __email__ = ["[email protected]", "[email protected]"] import random import urllib2 from search import GoogleSearch, SearchError import time from multiprocessing import Process from threading import Timer class shufflez: def __init__(self): self.word_list = 'lists/wordlist.txt' self.websites = 'lists/websites.txt' self.user_agent = 'lists/user_agent.txt' def together(self, *functions): process = [] for function in functions: s = Process(target=function) s.start() process.append(s) for s in process: s.join() def randomize(self, r, typ): '''Return Random List r (range): int typ : word | site | user-agent ''' lst = [] if typ == 'word': list_to_parse = self.word_list elif typ == 'site': list_to_parse = self.websites elif typ == 'user-agent': list_to_parse = self.user_agent a = open(list_to_parse, 'r') for i in a.readlines(): lst.append(i) random.shuffle(lst) if typ == 'site': return map(lambda x:x if 'http://' in x else 'http://' +x, lst)[0:int(r)] else: return lst[0:int(r)] def append_to_list(self, typ, lst): if typ == 'word': l = self.word_list elif typ == 'link': l = self.websites li = open(l, 'a') for i in lst: li.write(i+'\n') li.close() def open_url(self, url, user_agent): try: header = { 'User-Agent' : str(user_agent) } req = urllib2.Request(url, headers=header) response = urllib2.urlopen(req) print 'STATUS', response.getcode() except: pass def google(self, term): <|fim_middle|> mask = shufflez() def random_websites(): count = random.randint(1,15) for i, e, in zip(mask.randomize(10, 'site'), mask.randomize(10, 'user-agent')): if count == random.randint(1,15): break else: sleep_time = str(random.randint(1,5)) +'.'+ str(random.randint(1,9)) print 'VISITING', '\033[92m', i , '\033[0m', 'USING', '\033[94m', e, '\033[0m', 'SLEEPING FOR', '\033[95m', sleep_time, 'SECONDS', '\033[0m' time.sleep(float(sleep_time)) mask.open_url(i, e) print '\n' def random_google(): count = random.randint(1,15) for i in mask.randomize(10, 'word'): if count == random.randint(1,15): break else: sleep_time = str(random.randint(1,5)) +'.'+ str(random.randint(1,9)) print 'SEARCHING FOR', '\033[92m', i ,'\033[0m', 'SLEEPING FOR', '\033[95m', sleep_time, 'SECONDS', '\033[0m', '\n' time.sleep(float(sleep_time)) mask.google(i) #while True: # try: # mask.together(random_google(), random_websites()) # except KeyboardInterrupt: # print 'Exit' # break<|fim▁end|>
links_from_google = [] words_from_google = [] try: gs = GoogleSearch(term) gs.results_per_page = 10 results = gs.get_results() for res in results: words_from_google.append(res.title.encode('utf8')) print '\033[92mGot new words from Google...appending to list\n\033[0m' self.append_to_list('word', words_from_google) links_from_google.append(res.url.encode('utf8')) print '\033[92mGot new link from Google...appending to list\n\033[0m' self.append_to_list('link', links_from_google) except SearchError, e: print "Search failed: %s" % e
<|file_name|>shuffelz.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python '''# shufflez.py ''' # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # * Neither the name of the <organization> nor the # names of its contributors may be used to endorse or promote products # derived from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE # DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY # DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. __author__ = ["A'mmer Almadani:Mad_Dev", "sysbase.org"] __email__ = ["[email protected]", "[email protected]"] import random import urllib2 from search import GoogleSearch, SearchError import time from multiprocessing import Process from threading import Timer class shufflez: def __init__(self): self.word_list = 'lists/wordlist.txt' self.websites = 'lists/websites.txt' self.user_agent = 'lists/user_agent.txt' def together(self, *functions): process = [] for function in functions: s = Process(target=function) s.start() process.append(s) for s in process: s.join() def randomize(self, r, typ): '''Return Random List r (range): int typ : word | site | user-agent ''' lst = [] if typ == 'word': list_to_parse = self.word_list elif typ == 'site': list_to_parse = self.websites elif typ == 'user-agent': list_to_parse = self.user_agent a = open(list_to_parse, 'r') for i in a.readlines(): lst.append(i) random.shuffle(lst) if typ == 'site': return map(lambda x:x if 'http://' in x else 'http://' +x, lst)[0:int(r)] else: return lst[0:int(r)] def append_to_list(self, typ, lst): if typ == 'word': l = self.word_list elif typ == 'link': l = self.websites li = open(l, 'a') for i in lst: li.write(i+'\n') li.close() def open_url(self, url, user_agent): try: header = { 'User-Agent' : str(user_agent) } req = urllib2.Request(url, headers=header) response = urllib2.urlopen(req) print 'STATUS', response.getcode() except: pass def google(self, term): links_from_google = [] words_from_google = [] try: gs = GoogleSearch(term) gs.results_per_page = 10 results = gs.get_results() for res in results: words_from_google.append(res.title.encode('utf8')) print '\033[92mGot new words from Google...appending to list\n\033[0m' self.append_to_list('word', words_from_google) links_from_google.append(res.url.encode('utf8')) print '\033[92mGot new link from Google...appending to list\n\033[0m' self.append_to_list('link', links_from_google) except SearchError, e: print "Search failed: %s" % e mask = shufflez() def random_websites(): <|fim_middle|> def random_google(): count = random.randint(1,15) for i in mask.randomize(10, 'word'): if count == random.randint(1,15): break else: sleep_time = str(random.randint(1,5)) +'.'+ str(random.randint(1,9)) print 'SEARCHING FOR', '\033[92m', i ,'\033[0m', 'SLEEPING FOR', '\033[95m', sleep_time, 'SECONDS', '\033[0m', '\n' time.sleep(float(sleep_time)) mask.google(i) #while True: # try: # mask.together(random_google(), random_websites()) # except KeyboardInterrupt: # print 'Exit' # break<|fim▁end|>
count = random.randint(1,15) for i, e, in zip(mask.randomize(10, 'site'), mask.randomize(10, 'user-agent')): if count == random.randint(1,15): break else: sleep_time = str(random.randint(1,5)) +'.'+ str(random.randint(1,9)) print 'VISITING', '\033[92m', i , '\033[0m', 'USING', '\033[94m', e, '\033[0m', 'SLEEPING FOR', '\033[95m', sleep_time, 'SECONDS', '\033[0m' time.sleep(float(sleep_time)) mask.open_url(i, e) print '\n'
<|file_name|>shuffelz.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python '''# shufflez.py ''' # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # * Neither the name of the <organization> nor the # names of its contributors may be used to endorse or promote products # derived from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE # DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY # DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. __author__ = ["A'mmer Almadani:Mad_Dev", "sysbase.org"] __email__ = ["[email protected]", "[email protected]"] import random import urllib2 from search import GoogleSearch, SearchError import time from multiprocessing import Process from threading import Timer class shufflez: def __init__(self): self.word_list = 'lists/wordlist.txt' self.websites = 'lists/websites.txt' self.user_agent = 'lists/user_agent.txt' def together(self, *functions): process = [] for function in functions: s = Process(target=function) s.start() process.append(s) for s in process: s.join() def randomize(self, r, typ): '''Return Random List r (range): int typ : word | site | user-agent ''' lst = [] if typ == 'word': list_to_parse = self.word_list elif typ == 'site': list_to_parse = self.websites elif typ == 'user-agent': list_to_parse = self.user_agent a = open(list_to_parse, 'r') for i in a.readlines(): lst.append(i) random.shuffle(lst) if typ == 'site': return map(lambda x:x if 'http://' in x else 'http://' +x, lst)[0:int(r)] else: return lst[0:int(r)] def append_to_list(self, typ, lst): if typ == 'word': l = self.word_list elif typ == 'link': l = self.websites li = open(l, 'a') for i in lst: li.write(i+'\n') li.close() def open_url(self, url, user_agent): try: header = { 'User-Agent' : str(user_agent) } req = urllib2.Request(url, headers=header) response = urllib2.urlopen(req) print 'STATUS', response.getcode() except: pass def google(self, term): links_from_google = [] words_from_google = [] try: gs = GoogleSearch(term) gs.results_per_page = 10 results = gs.get_results() for res in results: words_from_google.append(res.title.encode('utf8')) print '\033[92mGot new words from Google...appending to list\n\033[0m' self.append_to_list('word', words_from_google) links_from_google.append(res.url.encode('utf8')) print '\033[92mGot new link from Google...appending to list\n\033[0m' self.append_to_list('link', links_from_google) except SearchError, e: print "Search failed: %s" % e mask = shufflez() def random_websites(): count = random.randint(1,15) for i, e, in zip(mask.randomize(10, 'site'), mask.randomize(10, 'user-agent')): if count == random.randint(1,15): break else: sleep_time = str(random.randint(1,5)) +'.'+ str(random.randint(1,9)) print 'VISITING', '\033[92m', i , '\033[0m', 'USING', '\033[94m', e, '\033[0m', 'SLEEPING FOR', '\033[95m', sleep_time, 'SECONDS', '\033[0m' time.sleep(float(sleep_time)) mask.open_url(i, e) print '\n' def random_google(): <|fim_middle|> #while True: # try: # mask.together(random_google(), random_websites()) # except KeyboardInterrupt: # print 'Exit' # break<|fim▁end|>
count = random.randint(1,15) for i in mask.randomize(10, 'word'): if count == random.randint(1,15): break else: sleep_time = str(random.randint(1,5)) +'.'+ str(random.randint(1,9)) print 'SEARCHING FOR', '\033[92m', i ,'\033[0m', 'SLEEPING FOR', '\033[95m', sleep_time, 'SECONDS', '\033[0m', '\n' time.sleep(float(sleep_time)) mask.google(i)
<|file_name|>shuffelz.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python '''# shufflez.py ''' # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # * Neither the name of the <organization> nor the # names of its contributors may be used to endorse or promote products # derived from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE # DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY # DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. __author__ = ["A'mmer Almadani:Mad_Dev", "sysbase.org"] __email__ = ["[email protected]", "[email protected]"] import random import urllib2 from search import GoogleSearch, SearchError import time from multiprocessing import Process from threading import Timer class shufflez: def __init__(self): self.word_list = 'lists/wordlist.txt' self.websites = 'lists/websites.txt' self.user_agent = 'lists/user_agent.txt' def together(self, *functions): process = [] for function in functions: s = Process(target=function) s.start() process.append(s) for s in process: s.join() def randomize(self, r, typ): '''Return Random List r (range): int typ : word | site | user-agent ''' lst = [] if typ == 'word': <|fim_middle|> elif typ == 'site': list_to_parse = self.websites elif typ == 'user-agent': list_to_parse = self.user_agent a = open(list_to_parse, 'r') for i in a.readlines(): lst.append(i) random.shuffle(lst) if typ == 'site': return map(lambda x:x if 'http://' in x else 'http://' +x, lst)[0:int(r)] else: return lst[0:int(r)] def append_to_list(self, typ, lst): if typ == 'word': l = self.word_list elif typ == 'link': l = self.websites li = open(l, 'a') for i in lst: li.write(i+'\n') li.close() def open_url(self, url, user_agent): try: header = { 'User-Agent' : str(user_agent) } req = urllib2.Request(url, headers=header) response = urllib2.urlopen(req) print 'STATUS', response.getcode() except: pass def google(self, term): links_from_google = [] words_from_google = [] try: gs = GoogleSearch(term) gs.results_per_page = 10 results = gs.get_results() for res in results: words_from_google.append(res.title.encode('utf8')) print '\033[92mGot new words from Google...appending to list\n\033[0m' self.append_to_list('word', words_from_google) links_from_google.append(res.url.encode('utf8')) print '\033[92mGot new link from Google...appending to list\n\033[0m' self.append_to_list('link', links_from_google) except SearchError, e: print "Search failed: %s" % e mask = shufflez() def random_websites(): count = random.randint(1,15) for i, e, in zip(mask.randomize(10, 'site'), mask.randomize(10, 'user-agent')): if count == random.randint(1,15): break else: sleep_time = str(random.randint(1,5)) +'.'+ str(random.randint(1,9)) print 'VISITING', '\033[92m', i , '\033[0m', 'USING', '\033[94m', e, '\033[0m', 'SLEEPING FOR', '\033[95m', sleep_time, 'SECONDS', '\033[0m' time.sleep(float(sleep_time)) mask.open_url(i, e) print '\n' def random_google(): count = random.randint(1,15) for i in mask.randomize(10, 'word'): if count == random.randint(1,15): break else: sleep_time = str(random.randint(1,5)) +'.'+ str(random.randint(1,9)) print 'SEARCHING FOR', '\033[92m', i ,'\033[0m', 'SLEEPING FOR', '\033[95m', sleep_time, 'SECONDS', '\033[0m', '\n' time.sleep(float(sleep_time)) mask.google(i) #while True: # try: # mask.together(random_google(), random_websites()) # except KeyboardInterrupt: # print 'Exit' # break<|fim▁end|>
list_to_parse = self.word_list
<|file_name|>shuffelz.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python '''# shufflez.py ''' # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # * Neither the name of the <organization> nor the # names of its contributors may be used to endorse or promote products # derived from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE # DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY # DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. __author__ = ["A'mmer Almadani:Mad_Dev", "sysbase.org"] __email__ = ["[email protected]", "[email protected]"] import random import urllib2 from search import GoogleSearch, SearchError import time from multiprocessing import Process from threading import Timer class shufflez: def __init__(self): self.word_list = 'lists/wordlist.txt' self.websites = 'lists/websites.txt' self.user_agent = 'lists/user_agent.txt' def together(self, *functions): process = [] for function in functions: s = Process(target=function) s.start() process.append(s) for s in process: s.join() def randomize(self, r, typ): '''Return Random List r (range): int typ : word | site | user-agent ''' lst = [] if typ == 'word': list_to_parse = self.word_list elif typ == 'site': <|fim_middle|> elif typ == 'user-agent': list_to_parse = self.user_agent a = open(list_to_parse, 'r') for i in a.readlines(): lst.append(i) random.shuffle(lst) if typ == 'site': return map(lambda x:x if 'http://' in x else 'http://' +x, lst)[0:int(r)] else: return lst[0:int(r)] def append_to_list(self, typ, lst): if typ == 'word': l = self.word_list elif typ == 'link': l = self.websites li = open(l, 'a') for i in lst: li.write(i+'\n') li.close() def open_url(self, url, user_agent): try: header = { 'User-Agent' : str(user_agent) } req = urllib2.Request(url, headers=header) response = urllib2.urlopen(req) print 'STATUS', response.getcode() except: pass def google(self, term): links_from_google = [] words_from_google = [] try: gs = GoogleSearch(term) gs.results_per_page = 10 results = gs.get_results() for res in results: words_from_google.append(res.title.encode('utf8')) print '\033[92mGot new words from Google...appending to list\n\033[0m' self.append_to_list('word', words_from_google) links_from_google.append(res.url.encode('utf8')) print '\033[92mGot new link from Google...appending to list\n\033[0m' self.append_to_list('link', links_from_google) except SearchError, e: print "Search failed: %s" % e mask = shufflez() def random_websites(): count = random.randint(1,15) for i, e, in zip(mask.randomize(10, 'site'), mask.randomize(10, 'user-agent')): if count == random.randint(1,15): break else: sleep_time = str(random.randint(1,5)) +'.'+ str(random.randint(1,9)) print 'VISITING', '\033[92m', i , '\033[0m', 'USING', '\033[94m', e, '\033[0m', 'SLEEPING FOR', '\033[95m', sleep_time, 'SECONDS', '\033[0m' time.sleep(float(sleep_time)) mask.open_url(i, e) print '\n' def random_google(): count = random.randint(1,15) for i in mask.randomize(10, 'word'): if count == random.randint(1,15): break else: sleep_time = str(random.randint(1,5)) +'.'+ str(random.randint(1,9)) print 'SEARCHING FOR', '\033[92m', i ,'\033[0m', 'SLEEPING FOR', '\033[95m', sleep_time, 'SECONDS', '\033[0m', '\n' time.sleep(float(sleep_time)) mask.google(i) #while True: # try: # mask.together(random_google(), random_websites()) # except KeyboardInterrupt: # print 'Exit' # break<|fim▁end|>
list_to_parse = self.websites
<|file_name|>shuffelz.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python '''# shufflez.py ''' # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # * Neither the name of the <organization> nor the # names of its contributors may be used to endorse or promote products # derived from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE # DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY # DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. __author__ = ["A'mmer Almadani:Mad_Dev", "sysbase.org"] __email__ = ["[email protected]", "[email protected]"] import random import urllib2 from search import GoogleSearch, SearchError import time from multiprocessing import Process from threading import Timer class shufflez: def __init__(self): self.word_list = 'lists/wordlist.txt' self.websites = 'lists/websites.txt' self.user_agent = 'lists/user_agent.txt' def together(self, *functions): process = [] for function in functions: s = Process(target=function) s.start() process.append(s) for s in process: s.join() def randomize(self, r, typ): '''Return Random List r (range): int typ : word | site | user-agent ''' lst = [] if typ == 'word': list_to_parse = self.word_list elif typ == 'site': list_to_parse = self.websites elif typ == 'user-agent': <|fim_middle|> a = open(list_to_parse, 'r') for i in a.readlines(): lst.append(i) random.shuffle(lst) if typ == 'site': return map(lambda x:x if 'http://' in x else 'http://' +x, lst)[0:int(r)] else: return lst[0:int(r)] def append_to_list(self, typ, lst): if typ == 'word': l = self.word_list elif typ == 'link': l = self.websites li = open(l, 'a') for i in lst: li.write(i+'\n') li.close() def open_url(self, url, user_agent): try: header = { 'User-Agent' : str(user_agent) } req = urllib2.Request(url, headers=header) response = urllib2.urlopen(req) print 'STATUS', response.getcode() except: pass def google(self, term): links_from_google = [] words_from_google = [] try: gs = GoogleSearch(term) gs.results_per_page = 10 results = gs.get_results() for res in results: words_from_google.append(res.title.encode('utf8')) print '\033[92mGot new words from Google...appending to list\n\033[0m' self.append_to_list('word', words_from_google) links_from_google.append(res.url.encode('utf8')) print '\033[92mGot new link from Google...appending to list\n\033[0m' self.append_to_list('link', links_from_google) except SearchError, e: print "Search failed: %s" % e mask = shufflez() def random_websites(): count = random.randint(1,15) for i, e, in zip(mask.randomize(10, 'site'), mask.randomize(10, 'user-agent')): if count == random.randint(1,15): break else: sleep_time = str(random.randint(1,5)) +'.'+ str(random.randint(1,9)) print 'VISITING', '\033[92m', i , '\033[0m', 'USING', '\033[94m', e, '\033[0m', 'SLEEPING FOR', '\033[95m', sleep_time, 'SECONDS', '\033[0m' time.sleep(float(sleep_time)) mask.open_url(i, e) print '\n' def random_google(): count = random.randint(1,15) for i in mask.randomize(10, 'word'): if count == random.randint(1,15): break else: sleep_time = str(random.randint(1,5)) +'.'+ str(random.randint(1,9)) print 'SEARCHING FOR', '\033[92m', i ,'\033[0m', 'SLEEPING FOR', '\033[95m', sleep_time, 'SECONDS', '\033[0m', '\n' time.sleep(float(sleep_time)) mask.google(i) #while True: # try: # mask.together(random_google(), random_websites()) # except KeyboardInterrupt: # print 'Exit' # break<|fim▁end|>
list_to_parse = self.user_agent
<|file_name|>shuffelz.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python '''# shufflez.py ''' # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # * Neither the name of the <organization> nor the # names of its contributors may be used to endorse or promote products # derived from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE # DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY # DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. __author__ = ["A'mmer Almadani:Mad_Dev", "sysbase.org"] __email__ = ["[email protected]", "[email protected]"] import random import urllib2 from search import GoogleSearch, SearchError import time from multiprocessing import Process from threading import Timer class shufflez: def __init__(self): self.word_list = 'lists/wordlist.txt' self.websites = 'lists/websites.txt' self.user_agent = 'lists/user_agent.txt' def together(self, *functions): process = [] for function in functions: s = Process(target=function) s.start() process.append(s) for s in process: s.join() def randomize(self, r, typ): '''Return Random List r (range): int typ : word | site | user-agent ''' lst = [] if typ == 'word': list_to_parse = self.word_list elif typ == 'site': list_to_parse = self.websites elif typ == 'user-agent': list_to_parse = self.user_agent a = open(list_to_parse, 'r') for i in a.readlines(): lst.append(i) random.shuffle(lst) if typ == 'site': <|fim_middle|> else: return lst[0:int(r)] def append_to_list(self, typ, lst): if typ == 'word': l = self.word_list elif typ == 'link': l = self.websites li = open(l, 'a') for i in lst: li.write(i+'\n') li.close() def open_url(self, url, user_agent): try: header = { 'User-Agent' : str(user_agent) } req = urllib2.Request(url, headers=header) response = urllib2.urlopen(req) print 'STATUS', response.getcode() except: pass def google(self, term): links_from_google = [] words_from_google = [] try: gs = GoogleSearch(term) gs.results_per_page = 10 results = gs.get_results() for res in results: words_from_google.append(res.title.encode('utf8')) print '\033[92mGot new words from Google...appending to list\n\033[0m' self.append_to_list('word', words_from_google) links_from_google.append(res.url.encode('utf8')) print '\033[92mGot new link from Google...appending to list\n\033[0m' self.append_to_list('link', links_from_google) except SearchError, e: print "Search failed: %s" % e mask = shufflez() def random_websites(): count = random.randint(1,15) for i, e, in zip(mask.randomize(10, 'site'), mask.randomize(10, 'user-agent')): if count == random.randint(1,15): break else: sleep_time = str(random.randint(1,5)) +'.'+ str(random.randint(1,9)) print 'VISITING', '\033[92m', i , '\033[0m', 'USING', '\033[94m', e, '\033[0m', 'SLEEPING FOR', '\033[95m', sleep_time, 'SECONDS', '\033[0m' time.sleep(float(sleep_time)) mask.open_url(i, e) print '\n' def random_google(): count = random.randint(1,15) for i in mask.randomize(10, 'word'): if count == random.randint(1,15): break else: sleep_time = str(random.randint(1,5)) +'.'+ str(random.randint(1,9)) print 'SEARCHING FOR', '\033[92m', i ,'\033[0m', 'SLEEPING FOR', '\033[95m', sleep_time, 'SECONDS', '\033[0m', '\n' time.sleep(float(sleep_time)) mask.google(i) #while True: # try: # mask.together(random_google(), random_websites()) # except KeyboardInterrupt: # print 'Exit' # break<|fim▁end|>
return map(lambda x:x if 'http://' in x else 'http://' +x, lst)[0:int(r)]
<|file_name|>shuffelz.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python '''# shufflez.py ''' # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # * Neither the name of the <organization> nor the # names of its contributors may be used to endorse or promote products # derived from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE # DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY # DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. __author__ = ["A'mmer Almadani:Mad_Dev", "sysbase.org"] __email__ = ["[email protected]", "[email protected]"] import random import urllib2 from search import GoogleSearch, SearchError import time from multiprocessing import Process from threading import Timer class shufflez: def __init__(self): self.word_list = 'lists/wordlist.txt' self.websites = 'lists/websites.txt' self.user_agent = 'lists/user_agent.txt' def together(self, *functions): process = [] for function in functions: s = Process(target=function) s.start() process.append(s) for s in process: s.join() def randomize(self, r, typ): '''Return Random List r (range): int typ : word | site | user-agent ''' lst = [] if typ == 'word': list_to_parse = self.word_list elif typ == 'site': list_to_parse = self.websites elif typ == 'user-agent': list_to_parse = self.user_agent a = open(list_to_parse, 'r') for i in a.readlines(): lst.append(i) random.shuffle(lst) if typ == 'site': return map(lambda x:x if 'http://' in x else 'http://' +x, lst)[0:int(r)] else: <|fim_middle|> def append_to_list(self, typ, lst): if typ == 'word': l = self.word_list elif typ == 'link': l = self.websites li = open(l, 'a') for i in lst: li.write(i+'\n') li.close() def open_url(self, url, user_agent): try: header = { 'User-Agent' : str(user_agent) } req = urllib2.Request(url, headers=header) response = urllib2.urlopen(req) print 'STATUS', response.getcode() except: pass def google(self, term): links_from_google = [] words_from_google = [] try: gs = GoogleSearch(term) gs.results_per_page = 10 results = gs.get_results() for res in results: words_from_google.append(res.title.encode('utf8')) print '\033[92mGot new words from Google...appending to list\n\033[0m' self.append_to_list('word', words_from_google) links_from_google.append(res.url.encode('utf8')) print '\033[92mGot new link from Google...appending to list\n\033[0m' self.append_to_list('link', links_from_google) except SearchError, e: print "Search failed: %s" % e mask = shufflez() def random_websites(): count = random.randint(1,15) for i, e, in zip(mask.randomize(10, 'site'), mask.randomize(10, 'user-agent')): if count == random.randint(1,15): break else: sleep_time = str(random.randint(1,5)) +'.'+ str(random.randint(1,9)) print 'VISITING', '\033[92m', i , '\033[0m', 'USING', '\033[94m', e, '\033[0m', 'SLEEPING FOR', '\033[95m', sleep_time, 'SECONDS', '\033[0m' time.sleep(float(sleep_time)) mask.open_url(i, e) print '\n' def random_google(): count = random.randint(1,15) for i in mask.randomize(10, 'word'): if count == random.randint(1,15): break else: sleep_time = str(random.randint(1,5)) +'.'+ str(random.randint(1,9)) print 'SEARCHING FOR', '\033[92m', i ,'\033[0m', 'SLEEPING FOR', '\033[95m', sleep_time, 'SECONDS', '\033[0m', '\n' time.sleep(float(sleep_time)) mask.google(i) #while True: # try: # mask.together(random_google(), random_websites()) # except KeyboardInterrupt: # print 'Exit' # break<|fim▁end|>
return lst[0:int(r)]
<|file_name|>shuffelz.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python '''# shufflez.py ''' # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # * Neither the name of the <organization> nor the # names of its contributors may be used to endorse or promote products # derived from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE # DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY # DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. __author__ = ["A'mmer Almadani:Mad_Dev", "sysbase.org"] __email__ = ["[email protected]", "[email protected]"] import random import urllib2 from search import GoogleSearch, SearchError import time from multiprocessing import Process from threading import Timer class shufflez: def __init__(self): self.word_list = 'lists/wordlist.txt' self.websites = 'lists/websites.txt' self.user_agent = 'lists/user_agent.txt' def together(self, *functions): process = [] for function in functions: s = Process(target=function) s.start() process.append(s) for s in process: s.join() def randomize(self, r, typ): '''Return Random List r (range): int typ : word | site | user-agent ''' lst = [] if typ == 'word': list_to_parse = self.word_list elif typ == 'site': list_to_parse = self.websites elif typ == 'user-agent': list_to_parse = self.user_agent a = open(list_to_parse, 'r') for i in a.readlines(): lst.append(i) random.shuffle(lst) if typ == 'site': return map(lambda x:x if 'http://' in x else 'http://' +x, lst)[0:int(r)] else: return lst[0:int(r)] def append_to_list(self, typ, lst): if typ == 'word': <|fim_middle|> elif typ == 'link': l = self.websites li = open(l, 'a') for i in lst: li.write(i+'\n') li.close() def open_url(self, url, user_agent): try: header = { 'User-Agent' : str(user_agent) } req = urllib2.Request(url, headers=header) response = urllib2.urlopen(req) print 'STATUS', response.getcode() except: pass def google(self, term): links_from_google = [] words_from_google = [] try: gs = GoogleSearch(term) gs.results_per_page = 10 results = gs.get_results() for res in results: words_from_google.append(res.title.encode('utf8')) print '\033[92mGot new words from Google...appending to list\n\033[0m' self.append_to_list('word', words_from_google) links_from_google.append(res.url.encode('utf8')) print '\033[92mGot new link from Google...appending to list\n\033[0m' self.append_to_list('link', links_from_google) except SearchError, e: print "Search failed: %s" % e mask = shufflez() def random_websites(): count = random.randint(1,15) for i, e, in zip(mask.randomize(10, 'site'), mask.randomize(10, 'user-agent')): if count == random.randint(1,15): break else: sleep_time = str(random.randint(1,5)) +'.'+ str(random.randint(1,9)) print 'VISITING', '\033[92m', i , '\033[0m', 'USING', '\033[94m', e, '\033[0m', 'SLEEPING FOR', '\033[95m', sleep_time, 'SECONDS', '\033[0m' time.sleep(float(sleep_time)) mask.open_url(i, e) print '\n' def random_google(): count = random.randint(1,15) for i in mask.randomize(10, 'word'): if count == random.randint(1,15): break else: sleep_time = str(random.randint(1,5)) +'.'+ str(random.randint(1,9)) print 'SEARCHING FOR', '\033[92m', i ,'\033[0m', 'SLEEPING FOR', '\033[95m', sleep_time, 'SECONDS', '\033[0m', '\n' time.sleep(float(sleep_time)) mask.google(i) #while True: # try: # mask.together(random_google(), random_websites()) # except KeyboardInterrupt: # print 'Exit' # break<|fim▁end|>
l = self.word_list
<|file_name|>shuffelz.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python '''# shufflez.py ''' # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # * Neither the name of the <organization> nor the # names of its contributors may be used to endorse or promote products # derived from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE # DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY # DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. __author__ = ["A'mmer Almadani:Mad_Dev", "sysbase.org"] __email__ = ["[email protected]", "[email protected]"] import random import urllib2 from search import GoogleSearch, SearchError import time from multiprocessing import Process from threading import Timer class shufflez: def __init__(self): self.word_list = 'lists/wordlist.txt' self.websites = 'lists/websites.txt' self.user_agent = 'lists/user_agent.txt' def together(self, *functions): process = [] for function in functions: s = Process(target=function) s.start() process.append(s) for s in process: s.join() def randomize(self, r, typ): '''Return Random List r (range): int typ : word | site | user-agent ''' lst = [] if typ == 'word': list_to_parse = self.word_list elif typ == 'site': list_to_parse = self.websites elif typ == 'user-agent': list_to_parse = self.user_agent a = open(list_to_parse, 'r') for i in a.readlines(): lst.append(i) random.shuffle(lst) if typ == 'site': return map(lambda x:x if 'http://' in x else 'http://' +x, lst)[0:int(r)] else: return lst[0:int(r)] def append_to_list(self, typ, lst): if typ == 'word': l = self.word_list elif typ == 'link': <|fim_middle|> li = open(l, 'a') for i in lst: li.write(i+'\n') li.close() def open_url(self, url, user_agent): try: header = { 'User-Agent' : str(user_agent) } req = urllib2.Request(url, headers=header) response = urllib2.urlopen(req) print 'STATUS', response.getcode() except: pass def google(self, term): links_from_google = [] words_from_google = [] try: gs = GoogleSearch(term) gs.results_per_page = 10 results = gs.get_results() for res in results: words_from_google.append(res.title.encode('utf8')) print '\033[92mGot new words from Google...appending to list\n\033[0m' self.append_to_list('word', words_from_google) links_from_google.append(res.url.encode('utf8')) print '\033[92mGot new link from Google...appending to list\n\033[0m' self.append_to_list('link', links_from_google) except SearchError, e: print "Search failed: %s" % e mask = shufflez() def random_websites(): count = random.randint(1,15) for i, e, in zip(mask.randomize(10, 'site'), mask.randomize(10, 'user-agent')): if count == random.randint(1,15): break else: sleep_time = str(random.randint(1,5)) +'.'+ str(random.randint(1,9)) print 'VISITING', '\033[92m', i , '\033[0m', 'USING', '\033[94m', e, '\033[0m', 'SLEEPING FOR', '\033[95m', sleep_time, 'SECONDS', '\033[0m' time.sleep(float(sleep_time)) mask.open_url(i, e) print '\n' def random_google(): count = random.randint(1,15) for i in mask.randomize(10, 'word'): if count == random.randint(1,15): break else: sleep_time = str(random.randint(1,5)) +'.'+ str(random.randint(1,9)) print 'SEARCHING FOR', '\033[92m', i ,'\033[0m', 'SLEEPING FOR', '\033[95m', sleep_time, 'SECONDS', '\033[0m', '\n' time.sleep(float(sleep_time)) mask.google(i) #while True: # try: # mask.together(random_google(), random_websites()) # except KeyboardInterrupt: # print 'Exit' # break<|fim▁end|>
l = self.websites
<|file_name|>shuffelz.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python '''# shufflez.py ''' # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # * Neither the name of the <organization> nor the # names of its contributors may be used to endorse or promote products # derived from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE # DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY # DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. __author__ = ["A'mmer Almadani:Mad_Dev", "sysbase.org"] __email__ = ["[email protected]", "[email protected]"] import random import urllib2 from search import GoogleSearch, SearchError import time from multiprocessing import Process from threading import Timer class shufflez: def __init__(self): self.word_list = 'lists/wordlist.txt' self.websites = 'lists/websites.txt' self.user_agent = 'lists/user_agent.txt' def together(self, *functions): process = [] for function in functions: s = Process(target=function) s.start() process.append(s) for s in process: s.join() def randomize(self, r, typ): '''Return Random List r (range): int typ : word | site | user-agent ''' lst = [] if typ == 'word': list_to_parse = self.word_list elif typ == 'site': list_to_parse = self.websites elif typ == 'user-agent': list_to_parse = self.user_agent a = open(list_to_parse, 'r') for i in a.readlines(): lst.append(i) random.shuffle(lst) if typ == 'site': return map(lambda x:x if 'http://' in x else 'http://' +x, lst)[0:int(r)] else: return lst[0:int(r)] def append_to_list(self, typ, lst): if typ == 'word': l = self.word_list elif typ == 'link': l = self.websites li = open(l, 'a') for i in lst: li.write(i+'\n') li.close() def open_url(self, url, user_agent): try: header = { 'User-Agent' : str(user_agent) } req = urllib2.Request(url, headers=header) response = urllib2.urlopen(req) print 'STATUS', response.getcode() except: pass def google(self, term): links_from_google = [] words_from_google = [] try: gs = GoogleSearch(term) gs.results_per_page = 10 results = gs.get_results() for res in results: words_from_google.append(res.title.encode('utf8')) print '\033[92mGot new words from Google...appending to list\n\033[0m' self.append_to_list('word', words_from_google) links_from_google.append(res.url.encode('utf8')) print '\033[92mGot new link from Google...appending to list\n\033[0m' self.append_to_list('link', links_from_google) except SearchError, e: print "Search failed: %s" % e mask = shufflez() def random_websites(): count = random.randint(1,15) for i, e, in zip(mask.randomize(10, 'site'), mask.randomize(10, 'user-agent')): if count == random.randint(1,15): <|fim_middle|> else: sleep_time = str(random.randint(1,5)) +'.'+ str(random.randint(1,9)) print 'VISITING', '\033[92m', i , '\033[0m', 'USING', '\033[94m', e, '\033[0m', 'SLEEPING FOR', '\033[95m', sleep_time, 'SECONDS', '\033[0m' time.sleep(float(sleep_time)) mask.open_url(i, e) print '\n' def random_google(): count = random.randint(1,15) for i in mask.randomize(10, 'word'): if count == random.randint(1,15): break else: sleep_time = str(random.randint(1,5)) +'.'+ str(random.randint(1,9)) print 'SEARCHING FOR', '\033[92m', i ,'\033[0m', 'SLEEPING FOR', '\033[95m', sleep_time, 'SECONDS', '\033[0m', '\n' time.sleep(float(sleep_time)) mask.google(i) #while True: # try: # mask.together(random_google(), random_websites()) # except KeyboardInterrupt: # print 'Exit' # break<|fim▁end|>
break
<|file_name|>shuffelz.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python '''# shufflez.py ''' # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # * Neither the name of the <organization> nor the # names of its contributors may be used to endorse or promote products # derived from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE # DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY # DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. __author__ = ["A'mmer Almadani:Mad_Dev", "sysbase.org"] __email__ = ["[email protected]", "[email protected]"] import random import urllib2 from search import GoogleSearch, SearchError import time from multiprocessing import Process from threading import Timer class shufflez: def __init__(self): self.word_list = 'lists/wordlist.txt' self.websites = 'lists/websites.txt' self.user_agent = 'lists/user_agent.txt' def together(self, *functions): process = [] for function in functions: s = Process(target=function) s.start() process.append(s) for s in process: s.join() def randomize(self, r, typ): '''Return Random List r (range): int typ : word | site | user-agent ''' lst = [] if typ == 'word': list_to_parse = self.word_list elif typ == 'site': list_to_parse = self.websites elif typ == 'user-agent': list_to_parse = self.user_agent a = open(list_to_parse, 'r') for i in a.readlines(): lst.append(i) random.shuffle(lst) if typ == 'site': return map(lambda x:x if 'http://' in x else 'http://' +x, lst)[0:int(r)] else: return lst[0:int(r)] def append_to_list(self, typ, lst): if typ == 'word': l = self.word_list elif typ == 'link': l = self.websites li = open(l, 'a') for i in lst: li.write(i+'\n') li.close() def open_url(self, url, user_agent): try: header = { 'User-Agent' : str(user_agent) } req = urllib2.Request(url, headers=header) response = urllib2.urlopen(req) print 'STATUS', response.getcode() except: pass def google(self, term): links_from_google = [] words_from_google = [] try: gs = GoogleSearch(term) gs.results_per_page = 10 results = gs.get_results() for res in results: words_from_google.append(res.title.encode('utf8')) print '\033[92mGot new words from Google...appending to list\n\033[0m' self.append_to_list('word', words_from_google) links_from_google.append(res.url.encode('utf8')) print '\033[92mGot new link from Google...appending to list\n\033[0m' self.append_to_list('link', links_from_google) except SearchError, e: print "Search failed: %s" % e mask = shufflez() def random_websites(): count = random.randint(1,15) for i, e, in zip(mask.randomize(10, 'site'), mask.randomize(10, 'user-agent')): if count == random.randint(1,15): break else: <|fim_middle|> def random_google(): count = random.randint(1,15) for i in mask.randomize(10, 'word'): if count == random.randint(1,15): break else: sleep_time = str(random.randint(1,5)) +'.'+ str(random.randint(1,9)) print 'SEARCHING FOR', '\033[92m', i ,'\033[0m', 'SLEEPING FOR', '\033[95m', sleep_time, 'SECONDS', '\033[0m', '\n' time.sleep(float(sleep_time)) mask.google(i) #while True: # try: # mask.together(random_google(), random_websites()) # except KeyboardInterrupt: # print 'Exit' # break<|fim▁end|>
sleep_time = str(random.randint(1,5)) +'.'+ str(random.randint(1,9)) print 'VISITING', '\033[92m', i , '\033[0m', 'USING', '\033[94m', e, '\033[0m', 'SLEEPING FOR', '\033[95m', sleep_time, 'SECONDS', '\033[0m' time.sleep(float(sleep_time)) mask.open_url(i, e) print '\n'
<|file_name|>shuffelz.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python '''# shufflez.py ''' # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # * Neither the name of the <organization> nor the # names of its contributors may be used to endorse or promote products # derived from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE # DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY # DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. __author__ = ["A'mmer Almadani:Mad_Dev", "sysbase.org"] __email__ = ["[email protected]", "[email protected]"] import random import urllib2 from search import GoogleSearch, SearchError import time from multiprocessing import Process from threading import Timer class shufflez: def __init__(self): self.word_list = 'lists/wordlist.txt' self.websites = 'lists/websites.txt' self.user_agent = 'lists/user_agent.txt' def together(self, *functions): process = [] for function in functions: s = Process(target=function) s.start() process.append(s) for s in process: s.join() def randomize(self, r, typ): '''Return Random List r (range): int typ : word | site | user-agent ''' lst = [] if typ == 'word': list_to_parse = self.word_list elif typ == 'site': list_to_parse = self.websites elif typ == 'user-agent': list_to_parse = self.user_agent a = open(list_to_parse, 'r') for i in a.readlines(): lst.append(i) random.shuffle(lst) if typ == 'site': return map(lambda x:x if 'http://' in x else 'http://' +x, lst)[0:int(r)] else: return lst[0:int(r)] def append_to_list(self, typ, lst): if typ == 'word': l = self.word_list elif typ == 'link': l = self.websites li = open(l, 'a') for i in lst: li.write(i+'\n') li.close() def open_url(self, url, user_agent): try: header = { 'User-Agent' : str(user_agent) } req = urllib2.Request(url, headers=header) response = urllib2.urlopen(req) print 'STATUS', response.getcode() except: pass def google(self, term): links_from_google = [] words_from_google = [] try: gs = GoogleSearch(term) gs.results_per_page = 10 results = gs.get_results() for res in results: words_from_google.append(res.title.encode('utf8')) print '\033[92mGot new words from Google...appending to list\n\033[0m' self.append_to_list('word', words_from_google) links_from_google.append(res.url.encode('utf8')) print '\033[92mGot new link from Google...appending to list\n\033[0m' self.append_to_list('link', links_from_google) except SearchError, e: print "Search failed: %s" % e mask = shufflez() def random_websites(): count = random.randint(1,15) for i, e, in zip(mask.randomize(10, 'site'), mask.randomize(10, 'user-agent')): if count == random.randint(1,15): break else: sleep_time = str(random.randint(1,5)) +'.'+ str(random.randint(1,9)) print 'VISITING', '\033[92m', i , '\033[0m', 'USING', '\033[94m', e, '\033[0m', 'SLEEPING FOR', '\033[95m', sleep_time, 'SECONDS', '\033[0m' time.sleep(float(sleep_time)) mask.open_url(i, e) print '\n' def random_google(): count = random.randint(1,15) for i in mask.randomize(10, 'word'): if count == random.randint(1,15): <|fim_middle|> else: sleep_time = str(random.randint(1,5)) +'.'+ str(random.randint(1,9)) print 'SEARCHING FOR', '\033[92m', i ,'\033[0m', 'SLEEPING FOR', '\033[95m', sleep_time, 'SECONDS', '\033[0m', '\n' time.sleep(float(sleep_time)) mask.google(i) #while True: # try: # mask.together(random_google(), random_websites()) # except KeyboardInterrupt: # print 'Exit' # break<|fim▁end|>
break
<|file_name|>shuffelz.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python '''# shufflez.py ''' # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # * Neither the name of the <organization> nor the # names of its contributors may be used to endorse or promote products # derived from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE # DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY # DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. __author__ = ["A'mmer Almadani:Mad_Dev", "sysbase.org"] __email__ = ["[email protected]", "[email protected]"] import random import urllib2 from search import GoogleSearch, SearchError import time from multiprocessing import Process from threading import Timer class shufflez: def __init__(self): self.word_list = 'lists/wordlist.txt' self.websites = 'lists/websites.txt' self.user_agent = 'lists/user_agent.txt' def together(self, *functions): process = [] for function in functions: s = Process(target=function) s.start() process.append(s) for s in process: s.join() def randomize(self, r, typ): '''Return Random List r (range): int typ : word | site | user-agent ''' lst = [] if typ == 'word': list_to_parse = self.word_list elif typ == 'site': list_to_parse = self.websites elif typ == 'user-agent': list_to_parse = self.user_agent a = open(list_to_parse, 'r') for i in a.readlines(): lst.append(i) random.shuffle(lst) if typ == 'site': return map(lambda x:x if 'http://' in x else 'http://' +x, lst)[0:int(r)] else: return lst[0:int(r)] def append_to_list(self, typ, lst): if typ == 'word': l = self.word_list elif typ == 'link': l = self.websites li = open(l, 'a') for i in lst: li.write(i+'\n') li.close() def open_url(self, url, user_agent): try: header = { 'User-Agent' : str(user_agent) } req = urllib2.Request(url, headers=header) response = urllib2.urlopen(req) print 'STATUS', response.getcode() except: pass def google(self, term): links_from_google = [] words_from_google = [] try: gs = GoogleSearch(term) gs.results_per_page = 10 results = gs.get_results() for res in results: words_from_google.append(res.title.encode('utf8')) print '\033[92mGot new words from Google...appending to list\n\033[0m' self.append_to_list('word', words_from_google) links_from_google.append(res.url.encode('utf8')) print '\033[92mGot new link from Google...appending to list\n\033[0m' self.append_to_list('link', links_from_google) except SearchError, e: print "Search failed: %s" % e mask = shufflez() def random_websites(): count = random.randint(1,15) for i, e, in zip(mask.randomize(10, 'site'), mask.randomize(10, 'user-agent')): if count == random.randint(1,15): break else: sleep_time = str(random.randint(1,5)) +'.'+ str(random.randint(1,9)) print 'VISITING', '\033[92m', i , '\033[0m', 'USING', '\033[94m', e, '\033[0m', 'SLEEPING FOR', '\033[95m', sleep_time, 'SECONDS', '\033[0m' time.sleep(float(sleep_time)) mask.open_url(i, e) print '\n' def random_google(): count = random.randint(1,15) for i in mask.randomize(10, 'word'): if count == random.randint(1,15): break else: <|fim_middle|> #while True: # try: # mask.together(random_google(), random_websites()) # except KeyboardInterrupt: # print 'Exit' # break<|fim▁end|>
sleep_time = str(random.randint(1,5)) +'.'+ str(random.randint(1,9)) print 'SEARCHING FOR', '\033[92m', i ,'\033[0m', 'SLEEPING FOR', '\033[95m', sleep_time, 'SECONDS', '\033[0m', '\n' time.sleep(float(sleep_time)) mask.google(i)
<|file_name|>shuffelz.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python '''# shufflez.py ''' # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # * Neither the name of the <organization> nor the # names of its contributors may be used to endorse or promote products # derived from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE # DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY # DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. __author__ = ["A'mmer Almadani:Mad_Dev", "sysbase.org"] __email__ = ["[email protected]", "[email protected]"] import random import urllib2 from search import GoogleSearch, SearchError import time from multiprocessing import Process from threading import Timer class shufflez: def <|fim_middle|>(self): self.word_list = 'lists/wordlist.txt' self.websites = 'lists/websites.txt' self.user_agent = 'lists/user_agent.txt' def together(self, *functions): process = [] for function in functions: s = Process(target=function) s.start() process.append(s) for s in process: s.join() def randomize(self, r, typ): '''Return Random List r (range): int typ : word | site | user-agent ''' lst = [] if typ == 'word': list_to_parse = self.word_list elif typ == 'site': list_to_parse = self.websites elif typ == 'user-agent': list_to_parse = self.user_agent a = open(list_to_parse, 'r') for i in a.readlines(): lst.append(i) random.shuffle(lst) if typ == 'site': return map(lambda x:x if 'http://' in x else 'http://' +x, lst)[0:int(r)] else: return lst[0:int(r)] def append_to_list(self, typ, lst): if typ == 'word': l = self.word_list elif typ == 'link': l = self.websites li = open(l, 'a') for i in lst: li.write(i+'\n') li.close() def open_url(self, url, user_agent): try: header = { 'User-Agent' : str(user_agent) } req = urllib2.Request(url, headers=header) response = urllib2.urlopen(req) print 'STATUS', response.getcode() except: pass def google(self, term): links_from_google = [] words_from_google = [] try: gs = GoogleSearch(term) gs.results_per_page = 10 results = gs.get_results() for res in results: words_from_google.append(res.title.encode('utf8')) print '\033[92mGot new words from Google...appending to list\n\033[0m' self.append_to_list('word', words_from_google) links_from_google.append(res.url.encode('utf8')) print '\033[92mGot new link from Google...appending to list\n\033[0m' self.append_to_list('link', links_from_google) except SearchError, e: print "Search failed: %s" % e mask = shufflez() def random_websites(): count = random.randint(1,15) for i, e, in zip(mask.randomize(10, 'site'), mask.randomize(10, 'user-agent')): if count == random.randint(1,15): break else: sleep_time = str(random.randint(1,5)) +'.'+ str(random.randint(1,9)) print 'VISITING', '\033[92m', i , '\033[0m', 'USING', '\033[94m', e, '\033[0m', 'SLEEPING FOR', '\033[95m', sleep_time, 'SECONDS', '\033[0m' time.sleep(float(sleep_time)) mask.open_url(i, e) print '\n' def random_google(): count = random.randint(1,15) for i in mask.randomize(10, 'word'): if count == random.randint(1,15): break else: sleep_time = str(random.randint(1,5)) +'.'+ str(random.randint(1,9)) print 'SEARCHING FOR', '\033[92m', i ,'\033[0m', 'SLEEPING FOR', '\033[95m', sleep_time, 'SECONDS', '\033[0m', '\n' time.sleep(float(sleep_time)) mask.google(i) #while True: # try: # mask.together(random_google(), random_websites()) # except KeyboardInterrupt: # print 'Exit' # break<|fim▁end|>
__init__
<|file_name|>shuffelz.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python '''# shufflez.py ''' # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # * Neither the name of the <organization> nor the # names of its contributors may be used to endorse or promote products # derived from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE # DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY # DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. __author__ = ["A'mmer Almadani:Mad_Dev", "sysbase.org"] __email__ = ["[email protected]", "[email protected]"] import random import urllib2 from search import GoogleSearch, SearchError import time from multiprocessing import Process from threading import Timer class shufflez: def __init__(self): self.word_list = 'lists/wordlist.txt' self.websites = 'lists/websites.txt' self.user_agent = 'lists/user_agent.txt' def <|fim_middle|>(self, *functions): process = [] for function in functions: s = Process(target=function) s.start() process.append(s) for s in process: s.join() def randomize(self, r, typ): '''Return Random List r (range): int typ : word | site | user-agent ''' lst = [] if typ == 'word': list_to_parse = self.word_list elif typ == 'site': list_to_parse = self.websites elif typ == 'user-agent': list_to_parse = self.user_agent a = open(list_to_parse, 'r') for i in a.readlines(): lst.append(i) random.shuffle(lst) if typ == 'site': return map(lambda x:x if 'http://' in x else 'http://' +x, lst)[0:int(r)] else: return lst[0:int(r)] def append_to_list(self, typ, lst): if typ == 'word': l = self.word_list elif typ == 'link': l = self.websites li = open(l, 'a') for i in lst: li.write(i+'\n') li.close() def open_url(self, url, user_agent): try: header = { 'User-Agent' : str(user_agent) } req = urllib2.Request(url, headers=header) response = urllib2.urlopen(req) print 'STATUS', response.getcode() except: pass def google(self, term): links_from_google = [] words_from_google = [] try: gs = GoogleSearch(term) gs.results_per_page = 10 results = gs.get_results() for res in results: words_from_google.append(res.title.encode('utf8')) print '\033[92mGot new words from Google...appending to list\n\033[0m' self.append_to_list('word', words_from_google) links_from_google.append(res.url.encode('utf8')) print '\033[92mGot new link from Google...appending to list\n\033[0m' self.append_to_list('link', links_from_google) except SearchError, e: print "Search failed: %s" % e mask = shufflez() def random_websites(): count = random.randint(1,15) for i, e, in zip(mask.randomize(10, 'site'), mask.randomize(10, 'user-agent')): if count == random.randint(1,15): break else: sleep_time = str(random.randint(1,5)) +'.'+ str(random.randint(1,9)) print 'VISITING', '\033[92m', i , '\033[0m', 'USING', '\033[94m', e, '\033[0m', 'SLEEPING FOR', '\033[95m', sleep_time, 'SECONDS', '\033[0m' time.sleep(float(sleep_time)) mask.open_url(i, e) print '\n' def random_google(): count = random.randint(1,15) for i in mask.randomize(10, 'word'): if count == random.randint(1,15): break else: sleep_time = str(random.randint(1,5)) +'.'+ str(random.randint(1,9)) print 'SEARCHING FOR', '\033[92m', i ,'\033[0m', 'SLEEPING FOR', '\033[95m', sleep_time, 'SECONDS', '\033[0m', '\n' time.sleep(float(sleep_time)) mask.google(i) #while True: # try: # mask.together(random_google(), random_websites()) # except KeyboardInterrupt: # print 'Exit' # break<|fim▁end|>
together
<|file_name|>shuffelz.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python '''# shufflez.py ''' # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # * Neither the name of the <organization> nor the # names of its contributors may be used to endorse or promote products # derived from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE # DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY # DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. __author__ = ["A'mmer Almadani:Mad_Dev", "sysbase.org"] __email__ = ["[email protected]", "[email protected]"] import random import urllib2 from search import GoogleSearch, SearchError import time from multiprocessing import Process from threading import Timer class shufflez: def __init__(self): self.word_list = 'lists/wordlist.txt' self.websites = 'lists/websites.txt' self.user_agent = 'lists/user_agent.txt' def together(self, *functions): process = [] for function in functions: s = Process(target=function) s.start() process.append(s) for s in process: s.join() def <|fim_middle|>(self, r, typ): '''Return Random List r (range): int typ : word | site | user-agent ''' lst = [] if typ == 'word': list_to_parse = self.word_list elif typ == 'site': list_to_parse = self.websites elif typ == 'user-agent': list_to_parse = self.user_agent a = open(list_to_parse, 'r') for i in a.readlines(): lst.append(i) random.shuffle(lst) if typ == 'site': return map(lambda x:x if 'http://' in x else 'http://' +x, lst)[0:int(r)] else: return lst[0:int(r)] def append_to_list(self, typ, lst): if typ == 'word': l = self.word_list elif typ == 'link': l = self.websites li = open(l, 'a') for i in lst: li.write(i+'\n') li.close() def open_url(self, url, user_agent): try: header = { 'User-Agent' : str(user_agent) } req = urllib2.Request(url, headers=header) response = urllib2.urlopen(req) print 'STATUS', response.getcode() except: pass def google(self, term): links_from_google = [] words_from_google = [] try: gs = GoogleSearch(term) gs.results_per_page = 10 results = gs.get_results() for res in results: words_from_google.append(res.title.encode('utf8')) print '\033[92mGot new words from Google...appending to list\n\033[0m' self.append_to_list('word', words_from_google) links_from_google.append(res.url.encode('utf8')) print '\033[92mGot new link from Google...appending to list\n\033[0m' self.append_to_list('link', links_from_google) except SearchError, e: print "Search failed: %s" % e mask = shufflez() def random_websites(): count = random.randint(1,15) for i, e, in zip(mask.randomize(10, 'site'), mask.randomize(10, 'user-agent')): if count == random.randint(1,15): break else: sleep_time = str(random.randint(1,5)) +'.'+ str(random.randint(1,9)) print 'VISITING', '\033[92m', i , '\033[0m', 'USING', '\033[94m', e, '\033[0m', 'SLEEPING FOR', '\033[95m', sleep_time, 'SECONDS', '\033[0m' time.sleep(float(sleep_time)) mask.open_url(i, e) print '\n' def random_google(): count = random.randint(1,15) for i in mask.randomize(10, 'word'): if count == random.randint(1,15): break else: sleep_time = str(random.randint(1,5)) +'.'+ str(random.randint(1,9)) print 'SEARCHING FOR', '\033[92m', i ,'\033[0m', 'SLEEPING FOR', '\033[95m', sleep_time, 'SECONDS', '\033[0m', '\n' time.sleep(float(sleep_time)) mask.google(i) #while True: # try: # mask.together(random_google(), random_websites()) # except KeyboardInterrupt: # print 'Exit' # break<|fim▁end|>
randomize
<|file_name|>shuffelz.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python '''# shufflez.py ''' # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # * Neither the name of the <organization> nor the # names of its contributors may be used to endorse or promote products # derived from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE # DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY # DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. __author__ = ["A'mmer Almadani:Mad_Dev", "sysbase.org"] __email__ = ["[email protected]", "[email protected]"] import random import urllib2 from search import GoogleSearch, SearchError import time from multiprocessing import Process from threading import Timer class shufflez: def __init__(self): self.word_list = 'lists/wordlist.txt' self.websites = 'lists/websites.txt' self.user_agent = 'lists/user_agent.txt' def together(self, *functions): process = [] for function in functions: s = Process(target=function) s.start() process.append(s) for s in process: s.join() def randomize(self, r, typ): '''Return Random List r (range): int typ : word | site | user-agent ''' lst = [] if typ == 'word': list_to_parse = self.word_list elif typ == 'site': list_to_parse = self.websites elif typ == 'user-agent': list_to_parse = self.user_agent a = open(list_to_parse, 'r') for i in a.readlines(): lst.append(i) random.shuffle(lst) if typ == 'site': return map(lambda x:x if 'http://' in x else 'http://' +x, lst)[0:int(r)] else: return lst[0:int(r)] def <|fim_middle|>(self, typ, lst): if typ == 'word': l = self.word_list elif typ == 'link': l = self.websites li = open(l, 'a') for i in lst: li.write(i+'\n') li.close() def open_url(self, url, user_agent): try: header = { 'User-Agent' : str(user_agent) } req = urllib2.Request(url, headers=header) response = urllib2.urlopen(req) print 'STATUS', response.getcode() except: pass def google(self, term): links_from_google = [] words_from_google = [] try: gs = GoogleSearch(term) gs.results_per_page = 10 results = gs.get_results() for res in results: words_from_google.append(res.title.encode('utf8')) print '\033[92mGot new words from Google...appending to list\n\033[0m' self.append_to_list('word', words_from_google) links_from_google.append(res.url.encode('utf8')) print '\033[92mGot new link from Google...appending to list\n\033[0m' self.append_to_list('link', links_from_google) except SearchError, e: print "Search failed: %s" % e mask = shufflez() def random_websites(): count = random.randint(1,15) for i, e, in zip(mask.randomize(10, 'site'), mask.randomize(10, 'user-agent')): if count == random.randint(1,15): break else: sleep_time = str(random.randint(1,5)) +'.'+ str(random.randint(1,9)) print 'VISITING', '\033[92m', i , '\033[0m', 'USING', '\033[94m', e, '\033[0m', 'SLEEPING FOR', '\033[95m', sleep_time, 'SECONDS', '\033[0m' time.sleep(float(sleep_time)) mask.open_url(i, e) print '\n' def random_google(): count = random.randint(1,15) for i in mask.randomize(10, 'word'): if count == random.randint(1,15): break else: sleep_time = str(random.randint(1,5)) +'.'+ str(random.randint(1,9)) print 'SEARCHING FOR', '\033[92m', i ,'\033[0m', 'SLEEPING FOR', '\033[95m', sleep_time, 'SECONDS', '\033[0m', '\n' time.sleep(float(sleep_time)) mask.google(i) #while True: # try: # mask.together(random_google(), random_websites()) # except KeyboardInterrupt: # print 'Exit' # break<|fim▁end|>
append_to_list
<|file_name|>shuffelz.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python '''# shufflez.py ''' # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # * Neither the name of the <organization> nor the # names of its contributors may be used to endorse or promote products # derived from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE # DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY # DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. __author__ = ["A'mmer Almadani:Mad_Dev", "sysbase.org"] __email__ = ["[email protected]", "[email protected]"] import random import urllib2 from search import GoogleSearch, SearchError import time from multiprocessing import Process from threading import Timer class shufflez: def __init__(self): self.word_list = 'lists/wordlist.txt' self.websites = 'lists/websites.txt' self.user_agent = 'lists/user_agent.txt' def together(self, *functions): process = [] for function in functions: s = Process(target=function) s.start() process.append(s) for s in process: s.join() def randomize(self, r, typ): '''Return Random List r (range): int typ : word | site | user-agent ''' lst = [] if typ == 'word': list_to_parse = self.word_list elif typ == 'site': list_to_parse = self.websites elif typ == 'user-agent': list_to_parse = self.user_agent a = open(list_to_parse, 'r') for i in a.readlines(): lst.append(i) random.shuffle(lst) if typ == 'site': return map(lambda x:x if 'http://' in x else 'http://' +x, lst)[0:int(r)] else: return lst[0:int(r)] def append_to_list(self, typ, lst): if typ == 'word': l = self.word_list elif typ == 'link': l = self.websites li = open(l, 'a') for i in lst: li.write(i+'\n') li.close() def <|fim_middle|>(self, url, user_agent): try: header = { 'User-Agent' : str(user_agent) } req = urllib2.Request(url, headers=header) response = urllib2.urlopen(req) print 'STATUS', response.getcode() except: pass def google(self, term): links_from_google = [] words_from_google = [] try: gs = GoogleSearch(term) gs.results_per_page = 10 results = gs.get_results() for res in results: words_from_google.append(res.title.encode('utf8')) print '\033[92mGot new words from Google...appending to list\n\033[0m' self.append_to_list('word', words_from_google) links_from_google.append(res.url.encode('utf8')) print '\033[92mGot new link from Google...appending to list\n\033[0m' self.append_to_list('link', links_from_google) except SearchError, e: print "Search failed: %s" % e mask = shufflez() def random_websites(): count = random.randint(1,15) for i, e, in zip(mask.randomize(10, 'site'), mask.randomize(10, 'user-agent')): if count == random.randint(1,15): break else: sleep_time = str(random.randint(1,5)) +'.'+ str(random.randint(1,9)) print 'VISITING', '\033[92m', i , '\033[0m', 'USING', '\033[94m', e, '\033[0m', 'SLEEPING FOR', '\033[95m', sleep_time, 'SECONDS', '\033[0m' time.sleep(float(sleep_time)) mask.open_url(i, e) print '\n' def random_google(): count = random.randint(1,15) for i in mask.randomize(10, 'word'): if count == random.randint(1,15): break else: sleep_time = str(random.randint(1,5)) +'.'+ str(random.randint(1,9)) print 'SEARCHING FOR', '\033[92m', i ,'\033[0m', 'SLEEPING FOR', '\033[95m', sleep_time, 'SECONDS', '\033[0m', '\n' time.sleep(float(sleep_time)) mask.google(i) #while True: # try: # mask.together(random_google(), random_websites()) # except KeyboardInterrupt: # print 'Exit' # break<|fim▁end|>
open_url
<|file_name|>shuffelz.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python '''# shufflez.py ''' # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # * Neither the name of the <organization> nor the # names of its contributors may be used to endorse or promote products # derived from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE # DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY # DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. __author__ = ["A'mmer Almadani:Mad_Dev", "sysbase.org"] __email__ = ["[email protected]", "[email protected]"] import random import urllib2 from search import GoogleSearch, SearchError import time from multiprocessing import Process from threading import Timer class shufflez: def __init__(self): self.word_list = 'lists/wordlist.txt' self.websites = 'lists/websites.txt' self.user_agent = 'lists/user_agent.txt' def together(self, *functions): process = [] for function in functions: s = Process(target=function) s.start() process.append(s) for s in process: s.join() def randomize(self, r, typ): '''Return Random List r (range): int typ : word | site | user-agent ''' lst = [] if typ == 'word': list_to_parse = self.word_list elif typ == 'site': list_to_parse = self.websites elif typ == 'user-agent': list_to_parse = self.user_agent a = open(list_to_parse, 'r') for i in a.readlines(): lst.append(i) random.shuffle(lst) if typ == 'site': return map(lambda x:x if 'http://' in x else 'http://' +x, lst)[0:int(r)] else: return lst[0:int(r)] def append_to_list(self, typ, lst): if typ == 'word': l = self.word_list elif typ == 'link': l = self.websites li = open(l, 'a') for i in lst: li.write(i+'\n') li.close() def open_url(self, url, user_agent): try: header = { 'User-Agent' : str(user_agent) } req = urllib2.Request(url, headers=header) response = urllib2.urlopen(req) print 'STATUS', response.getcode() except: pass def <|fim_middle|>(self, term): links_from_google = [] words_from_google = [] try: gs = GoogleSearch(term) gs.results_per_page = 10 results = gs.get_results() for res in results: words_from_google.append(res.title.encode('utf8')) print '\033[92mGot new words from Google...appending to list\n\033[0m' self.append_to_list('word', words_from_google) links_from_google.append(res.url.encode('utf8')) print '\033[92mGot new link from Google...appending to list\n\033[0m' self.append_to_list('link', links_from_google) except SearchError, e: print "Search failed: %s" % e mask = shufflez() def random_websites(): count = random.randint(1,15) for i, e, in zip(mask.randomize(10, 'site'), mask.randomize(10, 'user-agent')): if count == random.randint(1,15): break else: sleep_time = str(random.randint(1,5)) +'.'+ str(random.randint(1,9)) print 'VISITING', '\033[92m', i , '\033[0m', 'USING', '\033[94m', e, '\033[0m', 'SLEEPING FOR', '\033[95m', sleep_time, 'SECONDS', '\033[0m' time.sleep(float(sleep_time)) mask.open_url(i, e) print '\n' def random_google(): count = random.randint(1,15) for i in mask.randomize(10, 'word'): if count == random.randint(1,15): break else: sleep_time = str(random.randint(1,5)) +'.'+ str(random.randint(1,9)) print 'SEARCHING FOR', '\033[92m', i ,'\033[0m', 'SLEEPING FOR', '\033[95m', sleep_time, 'SECONDS', '\033[0m', '\n' time.sleep(float(sleep_time)) mask.google(i) #while True: # try: # mask.together(random_google(), random_websites()) # except KeyboardInterrupt: # print 'Exit' # break<|fim▁end|>
google
<|file_name|>shuffelz.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python '''# shufflez.py ''' # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # * Neither the name of the <organization> nor the # names of its contributors may be used to endorse or promote products # derived from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE # DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY # DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. __author__ = ["A'mmer Almadani:Mad_Dev", "sysbase.org"] __email__ = ["[email protected]", "[email protected]"] import random import urllib2 from search import GoogleSearch, SearchError import time from multiprocessing import Process from threading import Timer class shufflez: def __init__(self): self.word_list = 'lists/wordlist.txt' self.websites = 'lists/websites.txt' self.user_agent = 'lists/user_agent.txt' def together(self, *functions): process = [] for function in functions: s = Process(target=function) s.start() process.append(s) for s in process: s.join() def randomize(self, r, typ): '''Return Random List r (range): int typ : word | site | user-agent ''' lst = [] if typ == 'word': list_to_parse = self.word_list elif typ == 'site': list_to_parse = self.websites elif typ == 'user-agent': list_to_parse = self.user_agent a = open(list_to_parse, 'r') for i in a.readlines(): lst.append(i) random.shuffle(lst) if typ == 'site': return map(lambda x:x if 'http://' in x else 'http://' +x, lst)[0:int(r)] else: return lst[0:int(r)] def append_to_list(self, typ, lst): if typ == 'word': l = self.word_list elif typ == 'link': l = self.websites li = open(l, 'a') for i in lst: li.write(i+'\n') li.close() def open_url(self, url, user_agent): try: header = { 'User-Agent' : str(user_agent) } req = urllib2.Request(url, headers=header) response = urllib2.urlopen(req) print 'STATUS', response.getcode() except: pass def google(self, term): links_from_google = [] words_from_google = [] try: gs = GoogleSearch(term) gs.results_per_page = 10 results = gs.get_results() for res in results: words_from_google.append(res.title.encode('utf8')) print '\033[92mGot new words from Google...appending to list\n\033[0m' self.append_to_list('word', words_from_google) links_from_google.append(res.url.encode('utf8')) print '\033[92mGot new link from Google...appending to list\n\033[0m' self.append_to_list('link', links_from_google) except SearchError, e: print "Search failed: %s" % e mask = shufflez() def <|fim_middle|>(): count = random.randint(1,15) for i, e, in zip(mask.randomize(10, 'site'), mask.randomize(10, 'user-agent')): if count == random.randint(1,15): break else: sleep_time = str(random.randint(1,5)) +'.'+ str(random.randint(1,9)) print 'VISITING', '\033[92m', i , '\033[0m', 'USING', '\033[94m', e, '\033[0m', 'SLEEPING FOR', '\033[95m', sleep_time, 'SECONDS', '\033[0m' time.sleep(float(sleep_time)) mask.open_url(i, e) print '\n' def random_google(): count = random.randint(1,15) for i in mask.randomize(10, 'word'): if count == random.randint(1,15): break else: sleep_time = str(random.randint(1,5)) +'.'+ str(random.randint(1,9)) print 'SEARCHING FOR', '\033[92m', i ,'\033[0m', 'SLEEPING FOR', '\033[95m', sleep_time, 'SECONDS', '\033[0m', '\n' time.sleep(float(sleep_time)) mask.google(i) #while True: # try: # mask.together(random_google(), random_websites()) # except KeyboardInterrupt: # print 'Exit' # break<|fim▁end|>
random_websites
<|file_name|>shuffelz.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python '''# shufflez.py ''' # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # * Neither the name of the <organization> nor the # names of its contributors may be used to endorse or promote products # derived from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE # DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY # DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. __author__ = ["A'mmer Almadani:Mad_Dev", "sysbase.org"] __email__ = ["[email protected]", "[email protected]"] import random import urllib2 from search import GoogleSearch, SearchError import time from multiprocessing import Process from threading import Timer class shufflez: def __init__(self): self.word_list = 'lists/wordlist.txt' self.websites = 'lists/websites.txt' self.user_agent = 'lists/user_agent.txt' def together(self, *functions): process = [] for function in functions: s = Process(target=function) s.start() process.append(s) for s in process: s.join() def randomize(self, r, typ): '''Return Random List r (range): int typ : word | site | user-agent ''' lst = [] if typ == 'word': list_to_parse = self.word_list elif typ == 'site': list_to_parse = self.websites elif typ == 'user-agent': list_to_parse = self.user_agent a = open(list_to_parse, 'r') for i in a.readlines(): lst.append(i) random.shuffle(lst) if typ == 'site': return map(lambda x:x if 'http://' in x else 'http://' +x, lst)[0:int(r)] else: return lst[0:int(r)] def append_to_list(self, typ, lst): if typ == 'word': l = self.word_list elif typ == 'link': l = self.websites li = open(l, 'a') for i in lst: li.write(i+'\n') li.close() def open_url(self, url, user_agent): try: header = { 'User-Agent' : str(user_agent) } req = urllib2.Request(url, headers=header) response = urllib2.urlopen(req) print 'STATUS', response.getcode() except: pass def google(self, term): links_from_google = [] words_from_google = [] try: gs = GoogleSearch(term) gs.results_per_page = 10 results = gs.get_results() for res in results: words_from_google.append(res.title.encode('utf8')) print '\033[92mGot new words from Google...appending to list\n\033[0m' self.append_to_list('word', words_from_google) links_from_google.append(res.url.encode('utf8')) print '\033[92mGot new link from Google...appending to list\n\033[0m' self.append_to_list('link', links_from_google) except SearchError, e: print "Search failed: %s" % e mask = shufflez() def random_websites(): count = random.randint(1,15) for i, e, in zip(mask.randomize(10, 'site'), mask.randomize(10, 'user-agent')): if count == random.randint(1,15): break else: sleep_time = str(random.randint(1,5)) +'.'+ str(random.randint(1,9)) print 'VISITING', '\033[92m', i , '\033[0m', 'USING', '\033[94m', e, '\033[0m', 'SLEEPING FOR', '\033[95m', sleep_time, 'SECONDS', '\033[0m' time.sleep(float(sleep_time)) mask.open_url(i, e) print '\n' def <|fim_middle|>(): count = random.randint(1,15) for i in mask.randomize(10, 'word'): if count == random.randint(1,15): break else: sleep_time = str(random.randint(1,5)) +'.'+ str(random.randint(1,9)) print 'SEARCHING FOR', '\033[92m', i ,'\033[0m', 'SLEEPING FOR', '\033[95m', sleep_time, 'SECONDS', '\033[0m', '\n' time.sleep(float(sleep_time)) mask.google(i) #while True: # try: # mask.together(random_google(), random_websites()) # except KeyboardInterrupt: # print 'Exit' # break<|fim▁end|>
random_google
<|file_name|>congruences.py<|end_file_name|><|fim▁begin|>import primes as py def lcm(a, b): return a * b / gcd(a, b) def gcd(a, b): while b != 0: (a, b) = (b, a % b) return a # Returns two integers x, y such that gcd(a, b) = ax + by def egcd(a, b): if a == 0: return (0, 1) else: y, x = egcd(b % a, a) return (x - (b // a) * y, y) # Returns an integer x such that ax = 1(mod m) def modInverse(a, m): x, y = egcd(a, m)<|fim▁hole|>def reduceCongr(a, b, m): gcdAB = gcd(a, b) a /= gcdAB b /= gcdAB m /= gcd(gcdAB, m) modinv = modInverse(a, m) b *= modinv return (1, b, m) # Returns the incongruent solutions to the linear congruence ax = b(mod m) def linCongr(a, b, m): solutions = set() if (b % gcd(a, m) == 0): numSols = gcd(a, m) sol = (b * egcd(a, m)[0] / numSols) % m for i in xrange(0, numSols): solutions.add((sol + m * i / numSols) % m) return solutions # Uses the Chinese Remainder Theorem to solve a system of linear congruences def crt(congruences): x = 0 M = 1 for i in xrange(len(congruences)): M *= congruences[i][2] congruences[i] = reduceCongr(congruences[i][0], congruences[i][1], congruences[i][2]) for j in xrange(len(congruences)): m = congruences[j][2] if gcd(m, M/m) != 1: return None x += congruences[j][1] * modInverse(M/m, m) * M / m return x % M # Returns the incongruent solution to any system of linear congruences def linCongrSystem(congruences): newCongruences = [] for i in xrange(len(congruences)): congruences[i] = reduceCongr(congruences[i][0], congruences[i][1], congruences[i][2]) # Tests to see whether the system is solvable for j in xrange(len(congruences)): if congruences[i] != congruences[j]: if (congruences[i][1] - congruences[j][1]) % gcd(congruences[i][2], congruences[j][2]) != 0: return None # Splits moduli into prime powers pFactor = py.primeFactorization(congruences[i][2]) for term in pFactor: newCongruences.append((1, congruences[i][1], term[0] ** term[1])) # Discards redundant congruences newCongruences = sorted(newCongruences, key=lambda x: x[2], reverse = True) finalCongruences = [] for k in xrange(len(newCongruences)): isRedundant = False for l in xrange(0, k): if newCongruences[l][2] % newCongruences[k][2] == 0: isRedundant = True if not isRedundant: finalCongruences.append(newCongruences[k]) return crt(finalCongruences) # Returns incongruents solutions to a polynomial congruence def polyCongr(coefficients, m): solutions = [] for i in xrange(m): value = 0 for degree in xrange(len(coefficients)): value += coefficients[degree] * (i ** (len(coefficients) - degree - 1)) if value % m == 0: solutions.append(i) return solutions<|fim▁end|>
if gcd(a, m) == 1: return x % m # Reduces linear congruence to form x = b(mod m)
<|file_name|>congruences.py<|end_file_name|><|fim▁begin|>import primes as py def lcm(a, b): <|fim_middle|> def gcd(a, b): while b != 0: (a, b) = (b, a % b) return a # Returns two integers x, y such that gcd(a, b) = ax + by def egcd(a, b): if a == 0: return (0, 1) else: y, x = egcd(b % a, a) return (x - (b // a) * y, y) # Returns an integer x such that ax = 1(mod m) def modInverse(a, m): x, y = egcd(a, m) if gcd(a, m) == 1: return x % m # Reduces linear congruence to form x = b(mod m) def reduceCongr(a, b, m): gcdAB = gcd(a, b) a /= gcdAB b /= gcdAB m /= gcd(gcdAB, m) modinv = modInverse(a, m) b *= modinv return (1, b, m) # Returns the incongruent solutions to the linear congruence ax = b(mod m) def linCongr(a, b, m): solutions = set() if (b % gcd(a, m) == 0): numSols = gcd(a, m) sol = (b * egcd(a, m)[0] / numSols) % m for i in xrange(0, numSols): solutions.add((sol + m * i / numSols) % m) return solutions # Uses the Chinese Remainder Theorem to solve a system of linear congruences def crt(congruences): x = 0 M = 1 for i in xrange(len(congruences)): M *= congruences[i][2] congruences[i] = reduceCongr(congruences[i][0], congruences[i][1], congruences[i][2]) for j in xrange(len(congruences)): m = congruences[j][2] if gcd(m, M/m) != 1: return None x += congruences[j][1] * modInverse(M/m, m) * M / m return x % M # Returns the incongruent solution to any system of linear congruences def linCongrSystem(congruences): newCongruences = [] for i in xrange(len(congruences)): congruences[i] = reduceCongr(congruences[i][0], congruences[i][1], congruences[i][2]) # Tests to see whether the system is solvable for j in xrange(len(congruences)): if congruences[i] != congruences[j]: if (congruences[i][1] - congruences[j][1]) % gcd(congruences[i][2], congruences[j][2]) != 0: return None # Splits moduli into prime powers pFactor = py.primeFactorization(congruences[i][2]) for term in pFactor: newCongruences.append((1, congruences[i][1], term[0] ** term[1])) # Discards redundant congruences newCongruences = sorted(newCongruences, key=lambda x: x[2], reverse = True) finalCongruences = [] for k in xrange(len(newCongruences)): isRedundant = False for l in xrange(0, k): if newCongruences[l][2] % newCongruences[k][2] == 0: isRedundant = True if not isRedundant: finalCongruences.append(newCongruences[k]) return crt(finalCongruences) # Returns incongruents solutions to a polynomial congruence def polyCongr(coefficients, m): solutions = [] for i in xrange(m): value = 0 for degree in xrange(len(coefficients)): value += coefficients[degree] * (i ** (len(coefficients) - degree - 1)) if value % m == 0: solutions.append(i) return solutions <|fim▁end|>
return a * b / gcd(a, b)
<|file_name|>congruences.py<|end_file_name|><|fim▁begin|>import primes as py def lcm(a, b): return a * b / gcd(a, b) def gcd(a, b): <|fim_middle|> # Returns two integers x, y such that gcd(a, b) = ax + by def egcd(a, b): if a == 0: return (0, 1) else: y, x = egcd(b % a, a) return (x - (b // a) * y, y) # Returns an integer x such that ax = 1(mod m) def modInverse(a, m): x, y = egcd(a, m) if gcd(a, m) == 1: return x % m # Reduces linear congruence to form x = b(mod m) def reduceCongr(a, b, m): gcdAB = gcd(a, b) a /= gcdAB b /= gcdAB m /= gcd(gcdAB, m) modinv = modInverse(a, m) b *= modinv return (1, b, m) # Returns the incongruent solutions to the linear congruence ax = b(mod m) def linCongr(a, b, m): solutions = set() if (b % gcd(a, m) == 0): numSols = gcd(a, m) sol = (b * egcd(a, m)[0] / numSols) % m for i in xrange(0, numSols): solutions.add((sol + m * i / numSols) % m) return solutions # Uses the Chinese Remainder Theorem to solve a system of linear congruences def crt(congruences): x = 0 M = 1 for i in xrange(len(congruences)): M *= congruences[i][2] congruences[i] = reduceCongr(congruences[i][0], congruences[i][1], congruences[i][2]) for j in xrange(len(congruences)): m = congruences[j][2] if gcd(m, M/m) != 1: return None x += congruences[j][1] * modInverse(M/m, m) * M / m return x % M # Returns the incongruent solution to any system of linear congruences def linCongrSystem(congruences): newCongruences = [] for i in xrange(len(congruences)): congruences[i] = reduceCongr(congruences[i][0], congruences[i][1], congruences[i][2]) # Tests to see whether the system is solvable for j in xrange(len(congruences)): if congruences[i] != congruences[j]: if (congruences[i][1] - congruences[j][1]) % gcd(congruences[i][2], congruences[j][2]) != 0: return None # Splits moduli into prime powers pFactor = py.primeFactorization(congruences[i][2]) for term in pFactor: newCongruences.append((1, congruences[i][1], term[0] ** term[1])) # Discards redundant congruences newCongruences = sorted(newCongruences, key=lambda x: x[2], reverse = True) finalCongruences = [] for k in xrange(len(newCongruences)): isRedundant = False for l in xrange(0, k): if newCongruences[l][2] % newCongruences[k][2] == 0: isRedundant = True if not isRedundant: finalCongruences.append(newCongruences[k]) return crt(finalCongruences) # Returns incongruents solutions to a polynomial congruence def polyCongr(coefficients, m): solutions = [] for i in xrange(m): value = 0 for degree in xrange(len(coefficients)): value += coefficients[degree] * (i ** (len(coefficients) - degree - 1)) if value % m == 0: solutions.append(i) return solutions <|fim▁end|>
while b != 0: (a, b) = (b, a % b) return a
<|file_name|>congruences.py<|end_file_name|><|fim▁begin|>import primes as py def lcm(a, b): return a * b / gcd(a, b) def gcd(a, b): while b != 0: (a, b) = (b, a % b) return a # Returns two integers x, y such that gcd(a, b) = ax + by def egcd(a, b): <|fim_middle|> # Returns an integer x such that ax = 1(mod m) def modInverse(a, m): x, y = egcd(a, m) if gcd(a, m) == 1: return x % m # Reduces linear congruence to form x = b(mod m) def reduceCongr(a, b, m): gcdAB = gcd(a, b) a /= gcdAB b /= gcdAB m /= gcd(gcdAB, m) modinv = modInverse(a, m) b *= modinv return (1, b, m) # Returns the incongruent solutions to the linear congruence ax = b(mod m) def linCongr(a, b, m): solutions = set() if (b % gcd(a, m) == 0): numSols = gcd(a, m) sol = (b * egcd(a, m)[0] / numSols) % m for i in xrange(0, numSols): solutions.add((sol + m * i / numSols) % m) return solutions # Uses the Chinese Remainder Theorem to solve a system of linear congruences def crt(congruences): x = 0 M = 1 for i in xrange(len(congruences)): M *= congruences[i][2] congruences[i] = reduceCongr(congruences[i][0], congruences[i][1], congruences[i][2]) for j in xrange(len(congruences)): m = congruences[j][2] if gcd(m, M/m) != 1: return None x += congruences[j][1] * modInverse(M/m, m) * M / m return x % M # Returns the incongruent solution to any system of linear congruences def linCongrSystem(congruences): newCongruences = [] for i in xrange(len(congruences)): congruences[i] = reduceCongr(congruences[i][0], congruences[i][1], congruences[i][2]) # Tests to see whether the system is solvable for j in xrange(len(congruences)): if congruences[i] != congruences[j]: if (congruences[i][1] - congruences[j][1]) % gcd(congruences[i][2], congruences[j][2]) != 0: return None # Splits moduli into prime powers pFactor = py.primeFactorization(congruences[i][2]) for term in pFactor: newCongruences.append((1, congruences[i][1], term[0] ** term[1])) # Discards redundant congruences newCongruences = sorted(newCongruences, key=lambda x: x[2], reverse = True) finalCongruences = [] for k in xrange(len(newCongruences)): isRedundant = False for l in xrange(0, k): if newCongruences[l][2] % newCongruences[k][2] == 0: isRedundant = True if not isRedundant: finalCongruences.append(newCongruences[k]) return crt(finalCongruences) # Returns incongruents solutions to a polynomial congruence def polyCongr(coefficients, m): solutions = [] for i in xrange(m): value = 0 for degree in xrange(len(coefficients)): value += coefficients[degree] * (i ** (len(coefficients) - degree - 1)) if value % m == 0: solutions.append(i) return solutions <|fim▁end|>
if a == 0: return (0, 1) else: y, x = egcd(b % a, a) return (x - (b // a) * y, y)
<|file_name|>congruences.py<|end_file_name|><|fim▁begin|>import primes as py def lcm(a, b): return a * b / gcd(a, b) def gcd(a, b): while b != 0: (a, b) = (b, a % b) return a # Returns two integers x, y such that gcd(a, b) = ax + by def egcd(a, b): if a == 0: return (0, 1) else: y, x = egcd(b % a, a) return (x - (b // a) * y, y) # Returns an integer x such that ax = 1(mod m) def modInverse(a, m): <|fim_middle|> # Reduces linear congruence to form x = b(mod m) def reduceCongr(a, b, m): gcdAB = gcd(a, b) a /= gcdAB b /= gcdAB m /= gcd(gcdAB, m) modinv = modInverse(a, m) b *= modinv return (1, b, m) # Returns the incongruent solutions to the linear congruence ax = b(mod m) def linCongr(a, b, m): solutions = set() if (b % gcd(a, m) == 0): numSols = gcd(a, m) sol = (b * egcd(a, m)[0] / numSols) % m for i in xrange(0, numSols): solutions.add((sol + m * i / numSols) % m) return solutions # Uses the Chinese Remainder Theorem to solve a system of linear congruences def crt(congruences): x = 0 M = 1 for i in xrange(len(congruences)): M *= congruences[i][2] congruences[i] = reduceCongr(congruences[i][0], congruences[i][1], congruences[i][2]) for j in xrange(len(congruences)): m = congruences[j][2] if gcd(m, M/m) != 1: return None x += congruences[j][1] * modInverse(M/m, m) * M / m return x % M # Returns the incongruent solution to any system of linear congruences def linCongrSystem(congruences): newCongruences = [] for i in xrange(len(congruences)): congruences[i] = reduceCongr(congruences[i][0], congruences[i][1], congruences[i][2]) # Tests to see whether the system is solvable for j in xrange(len(congruences)): if congruences[i] != congruences[j]: if (congruences[i][1] - congruences[j][1]) % gcd(congruences[i][2], congruences[j][2]) != 0: return None # Splits moduli into prime powers pFactor = py.primeFactorization(congruences[i][2]) for term in pFactor: newCongruences.append((1, congruences[i][1], term[0] ** term[1])) # Discards redundant congruences newCongruences = sorted(newCongruences, key=lambda x: x[2], reverse = True) finalCongruences = [] for k in xrange(len(newCongruences)): isRedundant = False for l in xrange(0, k): if newCongruences[l][2] % newCongruences[k][2] == 0: isRedundant = True if not isRedundant: finalCongruences.append(newCongruences[k]) return crt(finalCongruences) # Returns incongruents solutions to a polynomial congruence def polyCongr(coefficients, m): solutions = [] for i in xrange(m): value = 0 for degree in xrange(len(coefficients)): value += coefficients[degree] * (i ** (len(coefficients) - degree - 1)) if value % m == 0: solutions.append(i) return solutions <|fim▁end|>
x, y = egcd(a, m) if gcd(a, m) == 1: return x % m
<|file_name|>congruences.py<|end_file_name|><|fim▁begin|>import primes as py def lcm(a, b): return a * b / gcd(a, b) def gcd(a, b): while b != 0: (a, b) = (b, a % b) return a # Returns two integers x, y such that gcd(a, b) = ax + by def egcd(a, b): if a == 0: return (0, 1) else: y, x = egcd(b % a, a) return (x - (b // a) * y, y) # Returns an integer x such that ax = 1(mod m) def modInverse(a, m): x, y = egcd(a, m) if gcd(a, m) == 1: return x % m # Reduces linear congruence to form x = b(mod m) def reduceCongr(a, b, m): <|fim_middle|> # Returns the incongruent solutions to the linear congruence ax = b(mod m) def linCongr(a, b, m): solutions = set() if (b % gcd(a, m) == 0): numSols = gcd(a, m) sol = (b * egcd(a, m)[0] / numSols) % m for i in xrange(0, numSols): solutions.add((sol + m * i / numSols) % m) return solutions # Uses the Chinese Remainder Theorem to solve a system of linear congruences def crt(congruences): x = 0 M = 1 for i in xrange(len(congruences)): M *= congruences[i][2] congruences[i] = reduceCongr(congruences[i][0], congruences[i][1], congruences[i][2]) for j in xrange(len(congruences)): m = congruences[j][2] if gcd(m, M/m) != 1: return None x += congruences[j][1] * modInverse(M/m, m) * M / m return x % M # Returns the incongruent solution to any system of linear congruences def linCongrSystem(congruences): newCongruences = [] for i in xrange(len(congruences)): congruences[i] = reduceCongr(congruences[i][0], congruences[i][1], congruences[i][2]) # Tests to see whether the system is solvable for j in xrange(len(congruences)): if congruences[i] != congruences[j]: if (congruences[i][1] - congruences[j][1]) % gcd(congruences[i][2], congruences[j][2]) != 0: return None # Splits moduli into prime powers pFactor = py.primeFactorization(congruences[i][2]) for term in pFactor: newCongruences.append((1, congruences[i][1], term[0] ** term[1])) # Discards redundant congruences newCongruences = sorted(newCongruences, key=lambda x: x[2], reverse = True) finalCongruences = [] for k in xrange(len(newCongruences)): isRedundant = False for l in xrange(0, k): if newCongruences[l][2] % newCongruences[k][2] == 0: isRedundant = True if not isRedundant: finalCongruences.append(newCongruences[k]) return crt(finalCongruences) # Returns incongruents solutions to a polynomial congruence def polyCongr(coefficients, m): solutions = [] for i in xrange(m): value = 0 for degree in xrange(len(coefficients)): value += coefficients[degree] * (i ** (len(coefficients) - degree - 1)) if value % m == 0: solutions.append(i) return solutions <|fim▁end|>
gcdAB = gcd(a, b) a /= gcdAB b /= gcdAB m /= gcd(gcdAB, m) modinv = modInverse(a, m) b *= modinv return (1, b, m)
<|file_name|>congruences.py<|end_file_name|><|fim▁begin|>import primes as py def lcm(a, b): return a * b / gcd(a, b) def gcd(a, b): while b != 0: (a, b) = (b, a % b) return a # Returns two integers x, y such that gcd(a, b) = ax + by def egcd(a, b): if a == 0: return (0, 1) else: y, x = egcd(b % a, a) return (x - (b // a) * y, y) # Returns an integer x such that ax = 1(mod m) def modInverse(a, m): x, y = egcd(a, m) if gcd(a, m) == 1: return x % m # Reduces linear congruence to form x = b(mod m) def reduceCongr(a, b, m): gcdAB = gcd(a, b) a /= gcdAB b /= gcdAB m /= gcd(gcdAB, m) modinv = modInverse(a, m) b *= modinv return (1, b, m) # Returns the incongruent solutions to the linear congruence ax = b(mod m) def linCongr(a, b, m): <|fim_middle|> # Uses the Chinese Remainder Theorem to solve a system of linear congruences def crt(congruences): x = 0 M = 1 for i in xrange(len(congruences)): M *= congruences[i][2] congruences[i] = reduceCongr(congruences[i][0], congruences[i][1], congruences[i][2]) for j in xrange(len(congruences)): m = congruences[j][2] if gcd(m, M/m) != 1: return None x += congruences[j][1] * modInverse(M/m, m) * M / m return x % M # Returns the incongruent solution to any system of linear congruences def linCongrSystem(congruences): newCongruences = [] for i in xrange(len(congruences)): congruences[i] = reduceCongr(congruences[i][0], congruences[i][1], congruences[i][2]) # Tests to see whether the system is solvable for j in xrange(len(congruences)): if congruences[i] != congruences[j]: if (congruences[i][1] - congruences[j][1]) % gcd(congruences[i][2], congruences[j][2]) != 0: return None # Splits moduli into prime powers pFactor = py.primeFactorization(congruences[i][2]) for term in pFactor: newCongruences.append((1, congruences[i][1], term[0] ** term[1])) # Discards redundant congruences newCongruences = sorted(newCongruences, key=lambda x: x[2], reverse = True) finalCongruences = [] for k in xrange(len(newCongruences)): isRedundant = False for l in xrange(0, k): if newCongruences[l][2] % newCongruences[k][2] == 0: isRedundant = True if not isRedundant: finalCongruences.append(newCongruences[k]) return crt(finalCongruences) # Returns incongruents solutions to a polynomial congruence def polyCongr(coefficients, m): solutions = [] for i in xrange(m): value = 0 for degree in xrange(len(coefficients)): value += coefficients[degree] * (i ** (len(coefficients) - degree - 1)) if value % m == 0: solutions.append(i) return solutions <|fim▁end|>
solutions = set() if (b % gcd(a, m) == 0): numSols = gcd(a, m) sol = (b * egcd(a, m)[0] / numSols) % m for i in xrange(0, numSols): solutions.add((sol + m * i / numSols) % m) return solutions
<|file_name|>congruences.py<|end_file_name|><|fim▁begin|>import primes as py def lcm(a, b): return a * b / gcd(a, b) def gcd(a, b): while b != 0: (a, b) = (b, a % b) return a # Returns two integers x, y such that gcd(a, b) = ax + by def egcd(a, b): if a == 0: return (0, 1) else: y, x = egcd(b % a, a) return (x - (b // a) * y, y) # Returns an integer x such that ax = 1(mod m) def modInverse(a, m): x, y = egcd(a, m) if gcd(a, m) == 1: return x % m # Reduces linear congruence to form x = b(mod m) def reduceCongr(a, b, m): gcdAB = gcd(a, b) a /= gcdAB b /= gcdAB m /= gcd(gcdAB, m) modinv = modInverse(a, m) b *= modinv return (1, b, m) # Returns the incongruent solutions to the linear congruence ax = b(mod m) def linCongr(a, b, m): solutions = set() if (b % gcd(a, m) == 0): numSols = gcd(a, m) sol = (b * egcd(a, m)[0] / numSols) % m for i in xrange(0, numSols): solutions.add((sol + m * i / numSols) % m) return solutions # Uses the Chinese Remainder Theorem to solve a system of linear congruences def crt(congruences): <|fim_middle|> # Returns the incongruent solution to any system of linear congruences def linCongrSystem(congruences): newCongruences = [] for i in xrange(len(congruences)): congruences[i] = reduceCongr(congruences[i][0], congruences[i][1], congruences[i][2]) # Tests to see whether the system is solvable for j in xrange(len(congruences)): if congruences[i] != congruences[j]: if (congruences[i][1] - congruences[j][1]) % gcd(congruences[i][2], congruences[j][2]) != 0: return None # Splits moduli into prime powers pFactor = py.primeFactorization(congruences[i][2]) for term in pFactor: newCongruences.append((1, congruences[i][1], term[0] ** term[1])) # Discards redundant congruences newCongruences = sorted(newCongruences, key=lambda x: x[2], reverse = True) finalCongruences = [] for k in xrange(len(newCongruences)): isRedundant = False for l in xrange(0, k): if newCongruences[l][2] % newCongruences[k][2] == 0: isRedundant = True if not isRedundant: finalCongruences.append(newCongruences[k]) return crt(finalCongruences) # Returns incongruents solutions to a polynomial congruence def polyCongr(coefficients, m): solutions = [] for i in xrange(m): value = 0 for degree in xrange(len(coefficients)): value += coefficients[degree] * (i ** (len(coefficients) - degree - 1)) if value % m == 0: solutions.append(i) return solutions <|fim▁end|>
x = 0 M = 1 for i in xrange(len(congruences)): M *= congruences[i][2] congruences[i] = reduceCongr(congruences[i][0], congruences[i][1], congruences[i][2]) for j in xrange(len(congruences)): m = congruences[j][2] if gcd(m, M/m) != 1: return None x += congruences[j][1] * modInverse(M/m, m) * M / m return x % M
<|file_name|>congruences.py<|end_file_name|><|fim▁begin|>import primes as py def lcm(a, b): return a * b / gcd(a, b) def gcd(a, b): while b != 0: (a, b) = (b, a % b) return a # Returns two integers x, y such that gcd(a, b) = ax + by def egcd(a, b): if a == 0: return (0, 1) else: y, x = egcd(b % a, a) return (x - (b // a) * y, y) # Returns an integer x such that ax = 1(mod m) def modInverse(a, m): x, y = egcd(a, m) if gcd(a, m) == 1: return x % m # Reduces linear congruence to form x = b(mod m) def reduceCongr(a, b, m): gcdAB = gcd(a, b) a /= gcdAB b /= gcdAB m /= gcd(gcdAB, m) modinv = modInverse(a, m) b *= modinv return (1, b, m) # Returns the incongruent solutions to the linear congruence ax = b(mod m) def linCongr(a, b, m): solutions = set() if (b % gcd(a, m) == 0): numSols = gcd(a, m) sol = (b * egcd(a, m)[0] / numSols) % m for i in xrange(0, numSols): solutions.add((sol + m * i / numSols) % m) return solutions # Uses the Chinese Remainder Theorem to solve a system of linear congruences def crt(congruences): x = 0 M = 1 for i in xrange(len(congruences)): M *= congruences[i][2] congruences[i] = reduceCongr(congruences[i][0], congruences[i][1], congruences[i][2]) for j in xrange(len(congruences)): m = congruences[j][2] if gcd(m, M/m) != 1: return None x += congruences[j][1] * modInverse(M/m, m) * M / m return x % M # Returns the incongruent solution to any system of linear congruences def linCongrSystem(congruences): <|fim_middle|> # Returns incongruents solutions to a polynomial congruence def polyCongr(coefficients, m): solutions = [] for i in xrange(m): value = 0 for degree in xrange(len(coefficients)): value += coefficients[degree] * (i ** (len(coefficients) - degree - 1)) if value % m == 0: solutions.append(i) return solutions <|fim▁end|>
newCongruences = [] for i in xrange(len(congruences)): congruences[i] = reduceCongr(congruences[i][0], congruences[i][1], congruences[i][2]) # Tests to see whether the system is solvable for j in xrange(len(congruences)): if congruences[i] != congruences[j]: if (congruences[i][1] - congruences[j][1]) % gcd(congruences[i][2], congruences[j][2]) != 0: return None # Splits moduli into prime powers pFactor = py.primeFactorization(congruences[i][2]) for term in pFactor: newCongruences.append((1, congruences[i][1], term[0] ** term[1])) # Discards redundant congruences newCongruences = sorted(newCongruences, key=lambda x: x[2], reverse = True) finalCongruences = [] for k in xrange(len(newCongruences)): isRedundant = False for l in xrange(0, k): if newCongruences[l][2] % newCongruences[k][2] == 0: isRedundant = True if not isRedundant: finalCongruences.append(newCongruences[k]) return crt(finalCongruences)
<|file_name|>congruences.py<|end_file_name|><|fim▁begin|>import primes as py def lcm(a, b): return a * b / gcd(a, b) def gcd(a, b): while b != 0: (a, b) = (b, a % b) return a # Returns two integers x, y such that gcd(a, b) = ax + by def egcd(a, b): if a == 0: return (0, 1) else: y, x = egcd(b % a, a) return (x - (b // a) * y, y) # Returns an integer x such that ax = 1(mod m) def modInverse(a, m): x, y = egcd(a, m) if gcd(a, m) == 1: return x % m # Reduces linear congruence to form x = b(mod m) def reduceCongr(a, b, m): gcdAB = gcd(a, b) a /= gcdAB b /= gcdAB m /= gcd(gcdAB, m) modinv = modInverse(a, m) b *= modinv return (1, b, m) # Returns the incongruent solutions to the linear congruence ax = b(mod m) def linCongr(a, b, m): solutions = set() if (b % gcd(a, m) == 0): numSols = gcd(a, m) sol = (b * egcd(a, m)[0] / numSols) % m for i in xrange(0, numSols): solutions.add((sol + m * i / numSols) % m) return solutions # Uses the Chinese Remainder Theorem to solve a system of linear congruences def crt(congruences): x = 0 M = 1 for i in xrange(len(congruences)): M *= congruences[i][2] congruences[i] = reduceCongr(congruences[i][0], congruences[i][1], congruences[i][2]) for j in xrange(len(congruences)): m = congruences[j][2] if gcd(m, M/m) != 1: return None x += congruences[j][1] * modInverse(M/m, m) * M / m return x % M # Returns the incongruent solution to any system of linear congruences def linCongrSystem(congruences): newCongruences = [] for i in xrange(len(congruences)): congruences[i] = reduceCongr(congruences[i][0], congruences[i][1], congruences[i][2]) # Tests to see whether the system is solvable for j in xrange(len(congruences)): if congruences[i] != congruences[j]: if (congruences[i][1] - congruences[j][1]) % gcd(congruences[i][2], congruences[j][2]) != 0: return None # Splits moduli into prime powers pFactor = py.primeFactorization(congruences[i][2]) for term in pFactor: newCongruences.append((1, congruences[i][1], term[0] ** term[1])) # Discards redundant congruences newCongruences = sorted(newCongruences, key=lambda x: x[2], reverse = True) finalCongruences = [] for k in xrange(len(newCongruences)): isRedundant = False for l in xrange(0, k): if newCongruences[l][2] % newCongruences[k][2] == 0: isRedundant = True if not isRedundant: finalCongruences.append(newCongruences[k]) return crt(finalCongruences) # Returns incongruents solutions to a polynomial congruence def polyCongr(coefficients, m): <|fim_middle|> <|fim▁end|>
solutions = [] for i in xrange(m): value = 0 for degree in xrange(len(coefficients)): value += coefficients[degree] * (i ** (len(coefficients) - degree - 1)) if value % m == 0: solutions.append(i) return solutions
<|file_name|>congruences.py<|end_file_name|><|fim▁begin|>import primes as py def lcm(a, b): return a * b / gcd(a, b) def gcd(a, b): while b != 0: (a, b) = (b, a % b) return a # Returns two integers x, y such that gcd(a, b) = ax + by def egcd(a, b): if a == 0: <|fim_middle|> else: y, x = egcd(b % a, a) return (x - (b // a) * y, y) # Returns an integer x such that ax = 1(mod m) def modInverse(a, m): x, y = egcd(a, m) if gcd(a, m) == 1: return x % m # Reduces linear congruence to form x = b(mod m) def reduceCongr(a, b, m): gcdAB = gcd(a, b) a /= gcdAB b /= gcdAB m /= gcd(gcdAB, m) modinv = modInverse(a, m) b *= modinv return (1, b, m) # Returns the incongruent solutions to the linear congruence ax = b(mod m) def linCongr(a, b, m): solutions = set() if (b % gcd(a, m) == 0): numSols = gcd(a, m) sol = (b * egcd(a, m)[0] / numSols) % m for i in xrange(0, numSols): solutions.add((sol + m * i / numSols) % m) return solutions # Uses the Chinese Remainder Theorem to solve a system of linear congruences def crt(congruences): x = 0 M = 1 for i in xrange(len(congruences)): M *= congruences[i][2] congruences[i] = reduceCongr(congruences[i][0], congruences[i][1], congruences[i][2]) for j in xrange(len(congruences)): m = congruences[j][2] if gcd(m, M/m) != 1: return None x += congruences[j][1] * modInverse(M/m, m) * M / m return x % M # Returns the incongruent solution to any system of linear congruences def linCongrSystem(congruences): newCongruences = [] for i in xrange(len(congruences)): congruences[i] = reduceCongr(congruences[i][0], congruences[i][1], congruences[i][2]) # Tests to see whether the system is solvable for j in xrange(len(congruences)): if congruences[i] != congruences[j]: if (congruences[i][1] - congruences[j][1]) % gcd(congruences[i][2], congruences[j][2]) != 0: return None # Splits moduli into prime powers pFactor = py.primeFactorization(congruences[i][2]) for term in pFactor: newCongruences.append((1, congruences[i][1], term[0] ** term[1])) # Discards redundant congruences newCongruences = sorted(newCongruences, key=lambda x: x[2], reverse = True) finalCongruences = [] for k in xrange(len(newCongruences)): isRedundant = False for l in xrange(0, k): if newCongruences[l][2] % newCongruences[k][2] == 0: isRedundant = True if not isRedundant: finalCongruences.append(newCongruences[k]) return crt(finalCongruences) # Returns incongruents solutions to a polynomial congruence def polyCongr(coefficients, m): solutions = [] for i in xrange(m): value = 0 for degree in xrange(len(coefficients)): value += coefficients[degree] * (i ** (len(coefficients) - degree - 1)) if value % m == 0: solutions.append(i) return solutions <|fim▁end|>
return (0, 1)
<|file_name|>congruences.py<|end_file_name|><|fim▁begin|>import primes as py def lcm(a, b): return a * b / gcd(a, b) def gcd(a, b): while b != 0: (a, b) = (b, a % b) return a # Returns two integers x, y such that gcd(a, b) = ax + by def egcd(a, b): if a == 0: return (0, 1) else: <|fim_middle|> # Returns an integer x such that ax = 1(mod m) def modInverse(a, m): x, y = egcd(a, m) if gcd(a, m) == 1: return x % m # Reduces linear congruence to form x = b(mod m) def reduceCongr(a, b, m): gcdAB = gcd(a, b) a /= gcdAB b /= gcdAB m /= gcd(gcdAB, m) modinv = modInverse(a, m) b *= modinv return (1, b, m) # Returns the incongruent solutions to the linear congruence ax = b(mod m) def linCongr(a, b, m): solutions = set() if (b % gcd(a, m) == 0): numSols = gcd(a, m) sol = (b * egcd(a, m)[0] / numSols) % m for i in xrange(0, numSols): solutions.add((sol + m * i / numSols) % m) return solutions # Uses the Chinese Remainder Theorem to solve a system of linear congruences def crt(congruences): x = 0 M = 1 for i in xrange(len(congruences)): M *= congruences[i][2] congruences[i] = reduceCongr(congruences[i][0], congruences[i][1], congruences[i][2]) for j in xrange(len(congruences)): m = congruences[j][2] if gcd(m, M/m) != 1: return None x += congruences[j][1] * modInverse(M/m, m) * M / m return x % M # Returns the incongruent solution to any system of linear congruences def linCongrSystem(congruences): newCongruences = [] for i in xrange(len(congruences)): congruences[i] = reduceCongr(congruences[i][0], congruences[i][1], congruences[i][2]) # Tests to see whether the system is solvable for j in xrange(len(congruences)): if congruences[i] != congruences[j]: if (congruences[i][1] - congruences[j][1]) % gcd(congruences[i][2], congruences[j][2]) != 0: return None # Splits moduli into prime powers pFactor = py.primeFactorization(congruences[i][2]) for term in pFactor: newCongruences.append((1, congruences[i][1], term[0] ** term[1])) # Discards redundant congruences newCongruences = sorted(newCongruences, key=lambda x: x[2], reverse = True) finalCongruences = [] for k in xrange(len(newCongruences)): isRedundant = False for l in xrange(0, k): if newCongruences[l][2] % newCongruences[k][2] == 0: isRedundant = True if not isRedundant: finalCongruences.append(newCongruences[k]) return crt(finalCongruences) # Returns incongruents solutions to a polynomial congruence def polyCongr(coefficients, m): solutions = [] for i in xrange(m): value = 0 for degree in xrange(len(coefficients)): value += coefficients[degree] * (i ** (len(coefficients) - degree - 1)) if value % m == 0: solutions.append(i) return solutions <|fim▁end|>
y, x = egcd(b % a, a) return (x - (b // a) * y, y)
<|file_name|>congruences.py<|end_file_name|><|fim▁begin|>import primes as py def lcm(a, b): return a * b / gcd(a, b) def gcd(a, b): while b != 0: (a, b) = (b, a % b) return a # Returns two integers x, y such that gcd(a, b) = ax + by def egcd(a, b): if a == 0: return (0, 1) else: y, x = egcd(b % a, a) return (x - (b // a) * y, y) # Returns an integer x such that ax = 1(mod m) def modInverse(a, m): x, y = egcd(a, m) if gcd(a, m) == 1: <|fim_middle|> # Reduces linear congruence to form x = b(mod m) def reduceCongr(a, b, m): gcdAB = gcd(a, b) a /= gcdAB b /= gcdAB m /= gcd(gcdAB, m) modinv = modInverse(a, m) b *= modinv return (1, b, m) # Returns the incongruent solutions to the linear congruence ax = b(mod m) def linCongr(a, b, m): solutions = set() if (b % gcd(a, m) == 0): numSols = gcd(a, m) sol = (b * egcd(a, m)[0] / numSols) % m for i in xrange(0, numSols): solutions.add((sol + m * i / numSols) % m) return solutions # Uses the Chinese Remainder Theorem to solve a system of linear congruences def crt(congruences): x = 0 M = 1 for i in xrange(len(congruences)): M *= congruences[i][2] congruences[i] = reduceCongr(congruences[i][0], congruences[i][1], congruences[i][2]) for j in xrange(len(congruences)): m = congruences[j][2] if gcd(m, M/m) != 1: return None x += congruences[j][1] * modInverse(M/m, m) * M / m return x % M # Returns the incongruent solution to any system of linear congruences def linCongrSystem(congruences): newCongruences = [] for i in xrange(len(congruences)): congruences[i] = reduceCongr(congruences[i][0], congruences[i][1], congruences[i][2]) # Tests to see whether the system is solvable for j in xrange(len(congruences)): if congruences[i] != congruences[j]: if (congruences[i][1] - congruences[j][1]) % gcd(congruences[i][2], congruences[j][2]) != 0: return None # Splits moduli into prime powers pFactor = py.primeFactorization(congruences[i][2]) for term in pFactor: newCongruences.append((1, congruences[i][1], term[0] ** term[1])) # Discards redundant congruences newCongruences = sorted(newCongruences, key=lambda x: x[2], reverse = True) finalCongruences = [] for k in xrange(len(newCongruences)): isRedundant = False for l in xrange(0, k): if newCongruences[l][2] % newCongruences[k][2] == 0: isRedundant = True if not isRedundant: finalCongruences.append(newCongruences[k]) return crt(finalCongruences) # Returns incongruents solutions to a polynomial congruence def polyCongr(coefficients, m): solutions = [] for i in xrange(m): value = 0 for degree in xrange(len(coefficients)): value += coefficients[degree] * (i ** (len(coefficients) - degree - 1)) if value % m == 0: solutions.append(i) return solutions <|fim▁end|>
return x % m
<|file_name|>congruences.py<|end_file_name|><|fim▁begin|>import primes as py def lcm(a, b): return a * b / gcd(a, b) def gcd(a, b): while b != 0: (a, b) = (b, a % b) return a # Returns two integers x, y such that gcd(a, b) = ax + by def egcd(a, b): if a == 0: return (0, 1) else: y, x = egcd(b % a, a) return (x - (b // a) * y, y) # Returns an integer x such that ax = 1(mod m) def modInverse(a, m): x, y = egcd(a, m) if gcd(a, m) == 1: return x % m # Reduces linear congruence to form x = b(mod m) def reduceCongr(a, b, m): gcdAB = gcd(a, b) a /= gcdAB b /= gcdAB m /= gcd(gcdAB, m) modinv = modInverse(a, m) b *= modinv return (1, b, m) # Returns the incongruent solutions to the linear congruence ax = b(mod m) def linCongr(a, b, m): solutions = set() if (b % gcd(a, m) == 0): <|fim_middle|> return solutions # Uses the Chinese Remainder Theorem to solve a system of linear congruences def crt(congruences): x = 0 M = 1 for i in xrange(len(congruences)): M *= congruences[i][2] congruences[i] = reduceCongr(congruences[i][0], congruences[i][1], congruences[i][2]) for j in xrange(len(congruences)): m = congruences[j][2] if gcd(m, M/m) != 1: return None x += congruences[j][1] * modInverse(M/m, m) * M / m return x % M # Returns the incongruent solution to any system of linear congruences def linCongrSystem(congruences): newCongruences = [] for i in xrange(len(congruences)): congruences[i] = reduceCongr(congruences[i][0], congruences[i][1], congruences[i][2]) # Tests to see whether the system is solvable for j in xrange(len(congruences)): if congruences[i] != congruences[j]: if (congruences[i][1] - congruences[j][1]) % gcd(congruences[i][2], congruences[j][2]) != 0: return None # Splits moduli into prime powers pFactor = py.primeFactorization(congruences[i][2]) for term in pFactor: newCongruences.append((1, congruences[i][1], term[0] ** term[1])) # Discards redundant congruences newCongruences = sorted(newCongruences, key=lambda x: x[2], reverse = True) finalCongruences = [] for k in xrange(len(newCongruences)): isRedundant = False for l in xrange(0, k): if newCongruences[l][2] % newCongruences[k][2] == 0: isRedundant = True if not isRedundant: finalCongruences.append(newCongruences[k]) return crt(finalCongruences) # Returns incongruents solutions to a polynomial congruence def polyCongr(coefficients, m): solutions = [] for i in xrange(m): value = 0 for degree in xrange(len(coefficients)): value += coefficients[degree] * (i ** (len(coefficients) - degree - 1)) if value % m == 0: solutions.append(i) return solutions <|fim▁end|>
numSols = gcd(a, m) sol = (b * egcd(a, m)[0] / numSols) % m for i in xrange(0, numSols): solutions.add((sol + m * i / numSols) % m)
<|file_name|>congruences.py<|end_file_name|><|fim▁begin|>import primes as py def lcm(a, b): return a * b / gcd(a, b) def gcd(a, b): while b != 0: (a, b) = (b, a % b) return a # Returns two integers x, y such that gcd(a, b) = ax + by def egcd(a, b): if a == 0: return (0, 1) else: y, x = egcd(b % a, a) return (x - (b // a) * y, y) # Returns an integer x such that ax = 1(mod m) def modInverse(a, m): x, y = egcd(a, m) if gcd(a, m) == 1: return x % m # Reduces linear congruence to form x = b(mod m) def reduceCongr(a, b, m): gcdAB = gcd(a, b) a /= gcdAB b /= gcdAB m /= gcd(gcdAB, m) modinv = modInverse(a, m) b *= modinv return (1, b, m) # Returns the incongruent solutions to the linear congruence ax = b(mod m) def linCongr(a, b, m): solutions = set() if (b % gcd(a, m) == 0): numSols = gcd(a, m) sol = (b * egcd(a, m)[0] / numSols) % m for i in xrange(0, numSols): solutions.add((sol + m * i / numSols) % m) return solutions # Uses the Chinese Remainder Theorem to solve a system of linear congruences def crt(congruences): x = 0 M = 1 for i in xrange(len(congruences)): M *= congruences[i][2] congruences[i] = reduceCongr(congruences[i][0], congruences[i][1], congruences[i][2]) for j in xrange(len(congruences)): m = congruences[j][2] if gcd(m, M/m) != 1: <|fim_middle|> x += congruences[j][1] * modInverse(M/m, m) * M / m return x % M # Returns the incongruent solution to any system of linear congruences def linCongrSystem(congruences): newCongruences = [] for i in xrange(len(congruences)): congruences[i] = reduceCongr(congruences[i][0], congruences[i][1], congruences[i][2]) # Tests to see whether the system is solvable for j in xrange(len(congruences)): if congruences[i] != congruences[j]: if (congruences[i][1] - congruences[j][1]) % gcd(congruences[i][2], congruences[j][2]) != 0: return None # Splits moduli into prime powers pFactor = py.primeFactorization(congruences[i][2]) for term in pFactor: newCongruences.append((1, congruences[i][1], term[0] ** term[1])) # Discards redundant congruences newCongruences = sorted(newCongruences, key=lambda x: x[2], reverse = True) finalCongruences = [] for k in xrange(len(newCongruences)): isRedundant = False for l in xrange(0, k): if newCongruences[l][2] % newCongruences[k][2] == 0: isRedundant = True if not isRedundant: finalCongruences.append(newCongruences[k]) return crt(finalCongruences) # Returns incongruents solutions to a polynomial congruence def polyCongr(coefficients, m): solutions = [] for i in xrange(m): value = 0 for degree in xrange(len(coefficients)): value += coefficients[degree] * (i ** (len(coefficients) - degree - 1)) if value % m == 0: solutions.append(i) return solutions <|fim▁end|>
return None
<|file_name|>congruences.py<|end_file_name|><|fim▁begin|>import primes as py def lcm(a, b): return a * b / gcd(a, b) def gcd(a, b): while b != 0: (a, b) = (b, a % b) return a # Returns two integers x, y such that gcd(a, b) = ax + by def egcd(a, b): if a == 0: return (0, 1) else: y, x = egcd(b % a, a) return (x - (b // a) * y, y) # Returns an integer x such that ax = 1(mod m) def modInverse(a, m): x, y = egcd(a, m) if gcd(a, m) == 1: return x % m # Reduces linear congruence to form x = b(mod m) def reduceCongr(a, b, m): gcdAB = gcd(a, b) a /= gcdAB b /= gcdAB m /= gcd(gcdAB, m) modinv = modInverse(a, m) b *= modinv return (1, b, m) # Returns the incongruent solutions to the linear congruence ax = b(mod m) def linCongr(a, b, m): solutions = set() if (b % gcd(a, m) == 0): numSols = gcd(a, m) sol = (b * egcd(a, m)[0] / numSols) % m for i in xrange(0, numSols): solutions.add((sol + m * i / numSols) % m) return solutions # Uses the Chinese Remainder Theorem to solve a system of linear congruences def crt(congruences): x = 0 M = 1 for i in xrange(len(congruences)): M *= congruences[i][2] congruences[i] = reduceCongr(congruences[i][0], congruences[i][1], congruences[i][2]) for j in xrange(len(congruences)): m = congruences[j][2] if gcd(m, M/m) != 1: return None x += congruences[j][1] * modInverse(M/m, m) * M / m return x % M # Returns the incongruent solution to any system of linear congruences def linCongrSystem(congruences): newCongruences = [] for i in xrange(len(congruences)): congruences[i] = reduceCongr(congruences[i][0], congruences[i][1], congruences[i][2]) # Tests to see whether the system is solvable for j in xrange(len(congruences)): if congruences[i] != congruences[j]: <|fim_middle|> # Splits moduli into prime powers pFactor = py.primeFactorization(congruences[i][2]) for term in pFactor: newCongruences.append((1, congruences[i][1], term[0] ** term[1])) # Discards redundant congruences newCongruences = sorted(newCongruences, key=lambda x: x[2], reverse = True) finalCongruences = [] for k in xrange(len(newCongruences)): isRedundant = False for l in xrange(0, k): if newCongruences[l][2] % newCongruences[k][2] == 0: isRedundant = True if not isRedundant: finalCongruences.append(newCongruences[k]) return crt(finalCongruences) # Returns incongruents solutions to a polynomial congruence def polyCongr(coefficients, m): solutions = [] for i in xrange(m): value = 0 for degree in xrange(len(coefficients)): value += coefficients[degree] * (i ** (len(coefficients) - degree - 1)) if value % m == 0: solutions.append(i) return solutions <|fim▁end|>
if (congruences[i][1] - congruences[j][1]) % gcd(congruences[i][2], congruences[j][2]) != 0: return None
<|file_name|>congruences.py<|end_file_name|><|fim▁begin|>import primes as py def lcm(a, b): return a * b / gcd(a, b) def gcd(a, b): while b != 0: (a, b) = (b, a % b) return a # Returns two integers x, y such that gcd(a, b) = ax + by def egcd(a, b): if a == 0: return (0, 1) else: y, x = egcd(b % a, a) return (x - (b // a) * y, y) # Returns an integer x such that ax = 1(mod m) def modInverse(a, m): x, y = egcd(a, m) if gcd(a, m) == 1: return x % m # Reduces linear congruence to form x = b(mod m) def reduceCongr(a, b, m): gcdAB = gcd(a, b) a /= gcdAB b /= gcdAB m /= gcd(gcdAB, m) modinv = modInverse(a, m) b *= modinv return (1, b, m) # Returns the incongruent solutions to the linear congruence ax = b(mod m) def linCongr(a, b, m): solutions = set() if (b % gcd(a, m) == 0): numSols = gcd(a, m) sol = (b * egcd(a, m)[0] / numSols) % m for i in xrange(0, numSols): solutions.add((sol + m * i / numSols) % m) return solutions # Uses the Chinese Remainder Theorem to solve a system of linear congruences def crt(congruences): x = 0 M = 1 for i in xrange(len(congruences)): M *= congruences[i][2] congruences[i] = reduceCongr(congruences[i][0], congruences[i][1], congruences[i][2]) for j in xrange(len(congruences)): m = congruences[j][2] if gcd(m, M/m) != 1: return None x += congruences[j][1] * modInverse(M/m, m) * M / m return x % M # Returns the incongruent solution to any system of linear congruences def linCongrSystem(congruences): newCongruences = [] for i in xrange(len(congruences)): congruences[i] = reduceCongr(congruences[i][0], congruences[i][1], congruences[i][2]) # Tests to see whether the system is solvable for j in xrange(len(congruences)): if congruences[i] != congruences[j]: if (congruences[i][1] - congruences[j][1]) % gcd(congruences[i][2], congruences[j][2]) != 0: <|fim_middle|> # Splits moduli into prime powers pFactor = py.primeFactorization(congruences[i][2]) for term in pFactor: newCongruences.append((1, congruences[i][1], term[0] ** term[1])) # Discards redundant congruences newCongruences = sorted(newCongruences, key=lambda x: x[2], reverse = True) finalCongruences = [] for k in xrange(len(newCongruences)): isRedundant = False for l in xrange(0, k): if newCongruences[l][2] % newCongruences[k][2] == 0: isRedundant = True if not isRedundant: finalCongruences.append(newCongruences[k]) return crt(finalCongruences) # Returns incongruents solutions to a polynomial congruence def polyCongr(coefficients, m): solutions = [] for i in xrange(m): value = 0 for degree in xrange(len(coefficients)): value += coefficients[degree] * (i ** (len(coefficients) - degree - 1)) if value % m == 0: solutions.append(i) return solutions <|fim▁end|>
return None
<|file_name|>congruences.py<|end_file_name|><|fim▁begin|>import primes as py def lcm(a, b): return a * b / gcd(a, b) def gcd(a, b): while b != 0: (a, b) = (b, a % b) return a # Returns two integers x, y such that gcd(a, b) = ax + by def egcd(a, b): if a == 0: return (0, 1) else: y, x = egcd(b % a, a) return (x - (b // a) * y, y) # Returns an integer x such that ax = 1(mod m) def modInverse(a, m): x, y = egcd(a, m) if gcd(a, m) == 1: return x % m # Reduces linear congruence to form x = b(mod m) def reduceCongr(a, b, m): gcdAB = gcd(a, b) a /= gcdAB b /= gcdAB m /= gcd(gcdAB, m) modinv = modInverse(a, m) b *= modinv return (1, b, m) # Returns the incongruent solutions to the linear congruence ax = b(mod m) def linCongr(a, b, m): solutions = set() if (b % gcd(a, m) == 0): numSols = gcd(a, m) sol = (b * egcd(a, m)[0] / numSols) % m for i in xrange(0, numSols): solutions.add((sol + m * i / numSols) % m) return solutions # Uses the Chinese Remainder Theorem to solve a system of linear congruences def crt(congruences): x = 0 M = 1 for i in xrange(len(congruences)): M *= congruences[i][2] congruences[i] = reduceCongr(congruences[i][0], congruences[i][1], congruences[i][2]) for j in xrange(len(congruences)): m = congruences[j][2] if gcd(m, M/m) != 1: return None x += congruences[j][1] * modInverse(M/m, m) * M / m return x % M # Returns the incongruent solution to any system of linear congruences def linCongrSystem(congruences): newCongruences = [] for i in xrange(len(congruences)): congruences[i] = reduceCongr(congruences[i][0], congruences[i][1], congruences[i][2]) # Tests to see whether the system is solvable for j in xrange(len(congruences)): if congruences[i] != congruences[j]: if (congruences[i][1] - congruences[j][1]) % gcd(congruences[i][2], congruences[j][2]) != 0: return None # Splits moduli into prime powers pFactor = py.primeFactorization(congruences[i][2]) for term in pFactor: newCongruences.append((1, congruences[i][1], term[0] ** term[1])) # Discards redundant congruences newCongruences = sorted(newCongruences, key=lambda x: x[2], reverse = True) finalCongruences = [] for k in xrange(len(newCongruences)): isRedundant = False for l in xrange(0, k): if newCongruences[l][2] % newCongruences[k][2] == 0: <|fim_middle|> if not isRedundant: finalCongruences.append(newCongruences[k]) return crt(finalCongruences) # Returns incongruents solutions to a polynomial congruence def polyCongr(coefficients, m): solutions = [] for i in xrange(m): value = 0 for degree in xrange(len(coefficients)): value += coefficients[degree] * (i ** (len(coefficients) - degree - 1)) if value % m == 0: solutions.append(i) return solutions <|fim▁end|>
isRedundant = True
<|file_name|>congruences.py<|end_file_name|><|fim▁begin|>import primes as py def lcm(a, b): return a * b / gcd(a, b) def gcd(a, b): while b != 0: (a, b) = (b, a % b) return a # Returns two integers x, y such that gcd(a, b) = ax + by def egcd(a, b): if a == 0: return (0, 1) else: y, x = egcd(b % a, a) return (x - (b // a) * y, y) # Returns an integer x such that ax = 1(mod m) def modInverse(a, m): x, y = egcd(a, m) if gcd(a, m) == 1: return x % m # Reduces linear congruence to form x = b(mod m) def reduceCongr(a, b, m): gcdAB = gcd(a, b) a /= gcdAB b /= gcdAB m /= gcd(gcdAB, m) modinv = modInverse(a, m) b *= modinv return (1, b, m) # Returns the incongruent solutions to the linear congruence ax = b(mod m) def linCongr(a, b, m): solutions = set() if (b % gcd(a, m) == 0): numSols = gcd(a, m) sol = (b * egcd(a, m)[0] / numSols) % m for i in xrange(0, numSols): solutions.add((sol + m * i / numSols) % m) return solutions # Uses the Chinese Remainder Theorem to solve a system of linear congruences def crt(congruences): x = 0 M = 1 for i in xrange(len(congruences)): M *= congruences[i][2] congruences[i] = reduceCongr(congruences[i][0], congruences[i][1], congruences[i][2]) for j in xrange(len(congruences)): m = congruences[j][2] if gcd(m, M/m) != 1: return None x += congruences[j][1] * modInverse(M/m, m) * M / m return x % M # Returns the incongruent solution to any system of linear congruences def linCongrSystem(congruences): newCongruences = [] for i in xrange(len(congruences)): congruences[i] = reduceCongr(congruences[i][0], congruences[i][1], congruences[i][2]) # Tests to see whether the system is solvable for j in xrange(len(congruences)): if congruences[i] != congruences[j]: if (congruences[i][1] - congruences[j][1]) % gcd(congruences[i][2], congruences[j][2]) != 0: return None # Splits moduli into prime powers pFactor = py.primeFactorization(congruences[i][2]) for term in pFactor: newCongruences.append((1, congruences[i][1], term[0] ** term[1])) # Discards redundant congruences newCongruences = sorted(newCongruences, key=lambda x: x[2], reverse = True) finalCongruences = [] for k in xrange(len(newCongruences)): isRedundant = False for l in xrange(0, k): if newCongruences[l][2] % newCongruences[k][2] == 0: isRedundant = True if not isRedundant: <|fim_middle|> return crt(finalCongruences) # Returns incongruents solutions to a polynomial congruence def polyCongr(coefficients, m): solutions = [] for i in xrange(m): value = 0 for degree in xrange(len(coefficients)): value += coefficients[degree] * (i ** (len(coefficients) - degree - 1)) if value % m == 0: solutions.append(i) return solutions <|fim▁end|>
finalCongruences.append(newCongruences[k])
<|file_name|>congruences.py<|end_file_name|><|fim▁begin|>import primes as py def lcm(a, b): return a * b / gcd(a, b) def gcd(a, b): while b != 0: (a, b) = (b, a % b) return a # Returns two integers x, y such that gcd(a, b) = ax + by def egcd(a, b): if a == 0: return (0, 1) else: y, x = egcd(b % a, a) return (x - (b // a) * y, y) # Returns an integer x such that ax = 1(mod m) def modInverse(a, m): x, y = egcd(a, m) if gcd(a, m) == 1: return x % m # Reduces linear congruence to form x = b(mod m) def reduceCongr(a, b, m): gcdAB = gcd(a, b) a /= gcdAB b /= gcdAB m /= gcd(gcdAB, m) modinv = modInverse(a, m) b *= modinv return (1, b, m) # Returns the incongruent solutions to the linear congruence ax = b(mod m) def linCongr(a, b, m): solutions = set() if (b % gcd(a, m) == 0): numSols = gcd(a, m) sol = (b * egcd(a, m)[0] / numSols) % m for i in xrange(0, numSols): solutions.add((sol + m * i / numSols) % m) return solutions # Uses the Chinese Remainder Theorem to solve a system of linear congruences def crt(congruences): x = 0 M = 1 for i in xrange(len(congruences)): M *= congruences[i][2] congruences[i] = reduceCongr(congruences[i][0], congruences[i][1], congruences[i][2]) for j in xrange(len(congruences)): m = congruences[j][2] if gcd(m, M/m) != 1: return None x += congruences[j][1] * modInverse(M/m, m) * M / m return x % M # Returns the incongruent solution to any system of linear congruences def linCongrSystem(congruences): newCongruences = [] for i in xrange(len(congruences)): congruences[i] = reduceCongr(congruences[i][0], congruences[i][1], congruences[i][2]) # Tests to see whether the system is solvable for j in xrange(len(congruences)): if congruences[i] != congruences[j]: if (congruences[i][1] - congruences[j][1]) % gcd(congruences[i][2], congruences[j][2]) != 0: return None # Splits moduli into prime powers pFactor = py.primeFactorization(congruences[i][2]) for term in pFactor: newCongruences.append((1, congruences[i][1], term[0] ** term[1])) # Discards redundant congruences newCongruences = sorted(newCongruences, key=lambda x: x[2], reverse = True) finalCongruences = [] for k in xrange(len(newCongruences)): isRedundant = False for l in xrange(0, k): if newCongruences[l][2] % newCongruences[k][2] == 0: isRedundant = True if not isRedundant: finalCongruences.append(newCongruences[k]) return crt(finalCongruences) # Returns incongruents solutions to a polynomial congruence def polyCongr(coefficients, m): solutions = [] for i in xrange(m): value = 0 for degree in xrange(len(coefficients)): value += coefficients[degree] * (i ** (len(coefficients) - degree - 1)) if value % m == 0: <|fim_middle|> return solutions <|fim▁end|>
solutions.append(i)
<|file_name|>congruences.py<|end_file_name|><|fim▁begin|>import primes as py def <|fim_middle|>(a, b): return a * b / gcd(a, b) def gcd(a, b): while b != 0: (a, b) = (b, a % b) return a # Returns two integers x, y such that gcd(a, b) = ax + by def egcd(a, b): if a == 0: return (0, 1) else: y, x = egcd(b % a, a) return (x - (b // a) * y, y) # Returns an integer x such that ax = 1(mod m) def modInverse(a, m): x, y = egcd(a, m) if gcd(a, m) == 1: return x % m # Reduces linear congruence to form x = b(mod m) def reduceCongr(a, b, m): gcdAB = gcd(a, b) a /= gcdAB b /= gcdAB m /= gcd(gcdAB, m) modinv = modInverse(a, m) b *= modinv return (1, b, m) # Returns the incongruent solutions to the linear congruence ax = b(mod m) def linCongr(a, b, m): solutions = set() if (b % gcd(a, m) == 0): numSols = gcd(a, m) sol = (b * egcd(a, m)[0] / numSols) % m for i in xrange(0, numSols): solutions.add((sol + m * i / numSols) % m) return solutions # Uses the Chinese Remainder Theorem to solve a system of linear congruences def crt(congruences): x = 0 M = 1 for i in xrange(len(congruences)): M *= congruences[i][2] congruences[i] = reduceCongr(congruences[i][0], congruences[i][1], congruences[i][2]) for j in xrange(len(congruences)): m = congruences[j][2] if gcd(m, M/m) != 1: return None x += congruences[j][1] * modInverse(M/m, m) * M / m return x % M # Returns the incongruent solution to any system of linear congruences def linCongrSystem(congruences): newCongruences = [] for i in xrange(len(congruences)): congruences[i] = reduceCongr(congruences[i][0], congruences[i][1], congruences[i][2]) # Tests to see whether the system is solvable for j in xrange(len(congruences)): if congruences[i] != congruences[j]: if (congruences[i][1] - congruences[j][1]) % gcd(congruences[i][2], congruences[j][2]) != 0: return None # Splits moduli into prime powers pFactor = py.primeFactorization(congruences[i][2]) for term in pFactor: newCongruences.append((1, congruences[i][1], term[0] ** term[1])) # Discards redundant congruences newCongruences = sorted(newCongruences, key=lambda x: x[2], reverse = True) finalCongruences = [] for k in xrange(len(newCongruences)): isRedundant = False for l in xrange(0, k): if newCongruences[l][2] % newCongruences[k][2] == 0: isRedundant = True if not isRedundant: finalCongruences.append(newCongruences[k]) return crt(finalCongruences) # Returns incongruents solutions to a polynomial congruence def polyCongr(coefficients, m): solutions = [] for i in xrange(m): value = 0 for degree in xrange(len(coefficients)): value += coefficients[degree] * (i ** (len(coefficients) - degree - 1)) if value % m == 0: solutions.append(i) return solutions <|fim▁end|>
lcm
<|file_name|>congruences.py<|end_file_name|><|fim▁begin|>import primes as py def lcm(a, b): return a * b / gcd(a, b) def <|fim_middle|>(a, b): while b != 0: (a, b) = (b, a % b) return a # Returns two integers x, y such that gcd(a, b) = ax + by def egcd(a, b): if a == 0: return (0, 1) else: y, x = egcd(b % a, a) return (x - (b // a) * y, y) # Returns an integer x such that ax = 1(mod m) def modInverse(a, m): x, y = egcd(a, m) if gcd(a, m) == 1: return x % m # Reduces linear congruence to form x = b(mod m) def reduceCongr(a, b, m): gcdAB = gcd(a, b) a /= gcdAB b /= gcdAB m /= gcd(gcdAB, m) modinv = modInverse(a, m) b *= modinv return (1, b, m) # Returns the incongruent solutions to the linear congruence ax = b(mod m) def linCongr(a, b, m): solutions = set() if (b % gcd(a, m) == 0): numSols = gcd(a, m) sol = (b * egcd(a, m)[0] / numSols) % m for i in xrange(0, numSols): solutions.add((sol + m * i / numSols) % m) return solutions # Uses the Chinese Remainder Theorem to solve a system of linear congruences def crt(congruences): x = 0 M = 1 for i in xrange(len(congruences)): M *= congruences[i][2] congruences[i] = reduceCongr(congruences[i][0], congruences[i][1], congruences[i][2]) for j in xrange(len(congruences)): m = congruences[j][2] if gcd(m, M/m) != 1: return None x += congruences[j][1] * modInverse(M/m, m) * M / m return x % M # Returns the incongruent solution to any system of linear congruences def linCongrSystem(congruences): newCongruences = [] for i in xrange(len(congruences)): congruences[i] = reduceCongr(congruences[i][0], congruences[i][1], congruences[i][2]) # Tests to see whether the system is solvable for j in xrange(len(congruences)): if congruences[i] != congruences[j]: if (congruences[i][1] - congruences[j][1]) % gcd(congruences[i][2], congruences[j][2]) != 0: return None # Splits moduli into prime powers pFactor = py.primeFactorization(congruences[i][2]) for term in pFactor: newCongruences.append((1, congruences[i][1], term[0] ** term[1])) # Discards redundant congruences newCongruences = sorted(newCongruences, key=lambda x: x[2], reverse = True) finalCongruences = [] for k in xrange(len(newCongruences)): isRedundant = False for l in xrange(0, k): if newCongruences[l][2] % newCongruences[k][2] == 0: isRedundant = True if not isRedundant: finalCongruences.append(newCongruences[k]) return crt(finalCongruences) # Returns incongruents solutions to a polynomial congruence def polyCongr(coefficients, m): solutions = [] for i in xrange(m): value = 0 for degree in xrange(len(coefficients)): value += coefficients[degree] * (i ** (len(coefficients) - degree - 1)) if value % m == 0: solutions.append(i) return solutions <|fim▁end|>
gcd
<|file_name|>congruences.py<|end_file_name|><|fim▁begin|>import primes as py def lcm(a, b): return a * b / gcd(a, b) def gcd(a, b): while b != 0: (a, b) = (b, a % b) return a # Returns two integers x, y such that gcd(a, b) = ax + by def <|fim_middle|>(a, b): if a == 0: return (0, 1) else: y, x = egcd(b % a, a) return (x - (b // a) * y, y) # Returns an integer x such that ax = 1(mod m) def modInverse(a, m): x, y = egcd(a, m) if gcd(a, m) == 1: return x % m # Reduces linear congruence to form x = b(mod m) def reduceCongr(a, b, m): gcdAB = gcd(a, b) a /= gcdAB b /= gcdAB m /= gcd(gcdAB, m) modinv = modInverse(a, m) b *= modinv return (1, b, m) # Returns the incongruent solutions to the linear congruence ax = b(mod m) def linCongr(a, b, m): solutions = set() if (b % gcd(a, m) == 0): numSols = gcd(a, m) sol = (b * egcd(a, m)[0] / numSols) % m for i in xrange(0, numSols): solutions.add((sol + m * i / numSols) % m) return solutions # Uses the Chinese Remainder Theorem to solve a system of linear congruences def crt(congruences): x = 0 M = 1 for i in xrange(len(congruences)): M *= congruences[i][2] congruences[i] = reduceCongr(congruences[i][0], congruences[i][1], congruences[i][2]) for j in xrange(len(congruences)): m = congruences[j][2] if gcd(m, M/m) != 1: return None x += congruences[j][1] * modInverse(M/m, m) * M / m return x % M # Returns the incongruent solution to any system of linear congruences def linCongrSystem(congruences): newCongruences = [] for i in xrange(len(congruences)): congruences[i] = reduceCongr(congruences[i][0], congruences[i][1], congruences[i][2]) # Tests to see whether the system is solvable for j in xrange(len(congruences)): if congruences[i] != congruences[j]: if (congruences[i][1] - congruences[j][1]) % gcd(congruences[i][2], congruences[j][2]) != 0: return None # Splits moduli into prime powers pFactor = py.primeFactorization(congruences[i][2]) for term in pFactor: newCongruences.append((1, congruences[i][1], term[0] ** term[1])) # Discards redundant congruences newCongruences = sorted(newCongruences, key=lambda x: x[2], reverse = True) finalCongruences = [] for k in xrange(len(newCongruences)): isRedundant = False for l in xrange(0, k): if newCongruences[l][2] % newCongruences[k][2] == 0: isRedundant = True if not isRedundant: finalCongruences.append(newCongruences[k]) return crt(finalCongruences) # Returns incongruents solutions to a polynomial congruence def polyCongr(coefficients, m): solutions = [] for i in xrange(m): value = 0 for degree in xrange(len(coefficients)): value += coefficients[degree] * (i ** (len(coefficients) - degree - 1)) if value % m == 0: solutions.append(i) return solutions <|fim▁end|>
egcd
<|file_name|>congruences.py<|end_file_name|><|fim▁begin|>import primes as py def lcm(a, b): return a * b / gcd(a, b) def gcd(a, b): while b != 0: (a, b) = (b, a % b) return a # Returns two integers x, y such that gcd(a, b) = ax + by def egcd(a, b): if a == 0: return (0, 1) else: y, x = egcd(b % a, a) return (x - (b // a) * y, y) # Returns an integer x such that ax = 1(mod m) def <|fim_middle|>(a, m): x, y = egcd(a, m) if gcd(a, m) == 1: return x % m # Reduces linear congruence to form x = b(mod m) def reduceCongr(a, b, m): gcdAB = gcd(a, b) a /= gcdAB b /= gcdAB m /= gcd(gcdAB, m) modinv = modInverse(a, m) b *= modinv return (1, b, m) # Returns the incongruent solutions to the linear congruence ax = b(mod m) def linCongr(a, b, m): solutions = set() if (b % gcd(a, m) == 0): numSols = gcd(a, m) sol = (b * egcd(a, m)[0] / numSols) % m for i in xrange(0, numSols): solutions.add((sol + m * i / numSols) % m) return solutions # Uses the Chinese Remainder Theorem to solve a system of linear congruences def crt(congruences): x = 0 M = 1 for i in xrange(len(congruences)): M *= congruences[i][2] congruences[i] = reduceCongr(congruences[i][0], congruences[i][1], congruences[i][2]) for j in xrange(len(congruences)): m = congruences[j][2] if gcd(m, M/m) != 1: return None x += congruences[j][1] * modInverse(M/m, m) * M / m return x % M # Returns the incongruent solution to any system of linear congruences def linCongrSystem(congruences): newCongruences = [] for i in xrange(len(congruences)): congruences[i] = reduceCongr(congruences[i][0], congruences[i][1], congruences[i][2]) # Tests to see whether the system is solvable for j in xrange(len(congruences)): if congruences[i] != congruences[j]: if (congruences[i][1] - congruences[j][1]) % gcd(congruences[i][2], congruences[j][2]) != 0: return None # Splits moduli into prime powers pFactor = py.primeFactorization(congruences[i][2]) for term in pFactor: newCongruences.append((1, congruences[i][1], term[0] ** term[1])) # Discards redundant congruences newCongruences = sorted(newCongruences, key=lambda x: x[2], reverse = True) finalCongruences = [] for k in xrange(len(newCongruences)): isRedundant = False for l in xrange(0, k): if newCongruences[l][2] % newCongruences[k][2] == 0: isRedundant = True if not isRedundant: finalCongruences.append(newCongruences[k]) return crt(finalCongruences) # Returns incongruents solutions to a polynomial congruence def polyCongr(coefficients, m): solutions = [] for i in xrange(m): value = 0 for degree in xrange(len(coefficients)): value += coefficients[degree] * (i ** (len(coefficients) - degree - 1)) if value % m == 0: solutions.append(i) return solutions <|fim▁end|>
modInverse
<|file_name|>congruences.py<|end_file_name|><|fim▁begin|>import primes as py def lcm(a, b): return a * b / gcd(a, b) def gcd(a, b): while b != 0: (a, b) = (b, a % b) return a # Returns two integers x, y such that gcd(a, b) = ax + by def egcd(a, b): if a == 0: return (0, 1) else: y, x = egcd(b % a, a) return (x - (b // a) * y, y) # Returns an integer x such that ax = 1(mod m) def modInverse(a, m): x, y = egcd(a, m) if gcd(a, m) == 1: return x % m # Reduces linear congruence to form x = b(mod m) def <|fim_middle|>(a, b, m): gcdAB = gcd(a, b) a /= gcdAB b /= gcdAB m /= gcd(gcdAB, m) modinv = modInverse(a, m) b *= modinv return (1, b, m) # Returns the incongruent solutions to the linear congruence ax = b(mod m) def linCongr(a, b, m): solutions = set() if (b % gcd(a, m) == 0): numSols = gcd(a, m) sol = (b * egcd(a, m)[0] / numSols) % m for i in xrange(0, numSols): solutions.add((sol + m * i / numSols) % m) return solutions # Uses the Chinese Remainder Theorem to solve a system of linear congruences def crt(congruences): x = 0 M = 1 for i in xrange(len(congruences)): M *= congruences[i][2] congruences[i] = reduceCongr(congruences[i][0], congruences[i][1], congruences[i][2]) for j in xrange(len(congruences)): m = congruences[j][2] if gcd(m, M/m) != 1: return None x += congruences[j][1] * modInverse(M/m, m) * M / m return x % M # Returns the incongruent solution to any system of linear congruences def linCongrSystem(congruences): newCongruences = [] for i in xrange(len(congruences)): congruences[i] = reduceCongr(congruences[i][0], congruences[i][1], congruences[i][2]) # Tests to see whether the system is solvable for j in xrange(len(congruences)): if congruences[i] != congruences[j]: if (congruences[i][1] - congruences[j][1]) % gcd(congruences[i][2], congruences[j][2]) != 0: return None # Splits moduli into prime powers pFactor = py.primeFactorization(congruences[i][2]) for term in pFactor: newCongruences.append((1, congruences[i][1], term[0] ** term[1])) # Discards redundant congruences newCongruences = sorted(newCongruences, key=lambda x: x[2], reverse = True) finalCongruences = [] for k in xrange(len(newCongruences)): isRedundant = False for l in xrange(0, k): if newCongruences[l][2] % newCongruences[k][2] == 0: isRedundant = True if not isRedundant: finalCongruences.append(newCongruences[k]) return crt(finalCongruences) # Returns incongruents solutions to a polynomial congruence def polyCongr(coefficients, m): solutions = [] for i in xrange(m): value = 0 for degree in xrange(len(coefficients)): value += coefficients[degree] * (i ** (len(coefficients) - degree - 1)) if value % m == 0: solutions.append(i) return solutions <|fim▁end|>
reduceCongr
<|file_name|>congruences.py<|end_file_name|><|fim▁begin|>import primes as py def lcm(a, b): return a * b / gcd(a, b) def gcd(a, b): while b != 0: (a, b) = (b, a % b) return a # Returns two integers x, y such that gcd(a, b) = ax + by def egcd(a, b): if a == 0: return (0, 1) else: y, x = egcd(b % a, a) return (x - (b // a) * y, y) # Returns an integer x such that ax = 1(mod m) def modInverse(a, m): x, y = egcd(a, m) if gcd(a, m) == 1: return x % m # Reduces linear congruence to form x = b(mod m) def reduceCongr(a, b, m): gcdAB = gcd(a, b) a /= gcdAB b /= gcdAB m /= gcd(gcdAB, m) modinv = modInverse(a, m) b *= modinv return (1, b, m) # Returns the incongruent solutions to the linear congruence ax = b(mod m) def <|fim_middle|>(a, b, m): solutions = set() if (b % gcd(a, m) == 0): numSols = gcd(a, m) sol = (b * egcd(a, m)[0] / numSols) % m for i in xrange(0, numSols): solutions.add((sol + m * i / numSols) % m) return solutions # Uses the Chinese Remainder Theorem to solve a system of linear congruences def crt(congruences): x = 0 M = 1 for i in xrange(len(congruences)): M *= congruences[i][2] congruences[i] = reduceCongr(congruences[i][0], congruences[i][1], congruences[i][2]) for j in xrange(len(congruences)): m = congruences[j][2] if gcd(m, M/m) != 1: return None x += congruences[j][1] * modInverse(M/m, m) * M / m return x % M # Returns the incongruent solution to any system of linear congruences def linCongrSystem(congruences): newCongruences = [] for i in xrange(len(congruences)): congruences[i] = reduceCongr(congruences[i][0], congruences[i][1], congruences[i][2]) # Tests to see whether the system is solvable for j in xrange(len(congruences)): if congruences[i] != congruences[j]: if (congruences[i][1] - congruences[j][1]) % gcd(congruences[i][2], congruences[j][2]) != 0: return None # Splits moduli into prime powers pFactor = py.primeFactorization(congruences[i][2]) for term in pFactor: newCongruences.append((1, congruences[i][1], term[0] ** term[1])) # Discards redundant congruences newCongruences = sorted(newCongruences, key=lambda x: x[2], reverse = True) finalCongruences = [] for k in xrange(len(newCongruences)): isRedundant = False for l in xrange(0, k): if newCongruences[l][2] % newCongruences[k][2] == 0: isRedundant = True if not isRedundant: finalCongruences.append(newCongruences[k]) return crt(finalCongruences) # Returns incongruents solutions to a polynomial congruence def polyCongr(coefficients, m): solutions = [] for i in xrange(m): value = 0 for degree in xrange(len(coefficients)): value += coefficients[degree] * (i ** (len(coefficients) - degree - 1)) if value % m == 0: solutions.append(i) return solutions <|fim▁end|>
linCongr
<|file_name|>congruences.py<|end_file_name|><|fim▁begin|>import primes as py def lcm(a, b): return a * b / gcd(a, b) def gcd(a, b): while b != 0: (a, b) = (b, a % b) return a # Returns two integers x, y such that gcd(a, b) = ax + by def egcd(a, b): if a == 0: return (0, 1) else: y, x = egcd(b % a, a) return (x - (b // a) * y, y) # Returns an integer x such that ax = 1(mod m) def modInverse(a, m): x, y = egcd(a, m) if gcd(a, m) == 1: return x % m # Reduces linear congruence to form x = b(mod m) def reduceCongr(a, b, m): gcdAB = gcd(a, b) a /= gcdAB b /= gcdAB m /= gcd(gcdAB, m) modinv = modInverse(a, m) b *= modinv return (1, b, m) # Returns the incongruent solutions to the linear congruence ax = b(mod m) def linCongr(a, b, m): solutions = set() if (b % gcd(a, m) == 0): numSols = gcd(a, m) sol = (b * egcd(a, m)[0] / numSols) % m for i in xrange(0, numSols): solutions.add((sol + m * i / numSols) % m) return solutions # Uses the Chinese Remainder Theorem to solve a system of linear congruences def <|fim_middle|>(congruences): x = 0 M = 1 for i in xrange(len(congruences)): M *= congruences[i][2] congruences[i] = reduceCongr(congruences[i][0], congruences[i][1], congruences[i][2]) for j in xrange(len(congruences)): m = congruences[j][2] if gcd(m, M/m) != 1: return None x += congruences[j][1] * modInverse(M/m, m) * M / m return x % M # Returns the incongruent solution to any system of linear congruences def linCongrSystem(congruences): newCongruences = [] for i in xrange(len(congruences)): congruences[i] = reduceCongr(congruences[i][0], congruences[i][1], congruences[i][2]) # Tests to see whether the system is solvable for j in xrange(len(congruences)): if congruences[i] != congruences[j]: if (congruences[i][1] - congruences[j][1]) % gcd(congruences[i][2], congruences[j][2]) != 0: return None # Splits moduli into prime powers pFactor = py.primeFactorization(congruences[i][2]) for term in pFactor: newCongruences.append((1, congruences[i][1], term[0] ** term[1])) # Discards redundant congruences newCongruences = sorted(newCongruences, key=lambda x: x[2], reverse = True) finalCongruences = [] for k in xrange(len(newCongruences)): isRedundant = False for l in xrange(0, k): if newCongruences[l][2] % newCongruences[k][2] == 0: isRedundant = True if not isRedundant: finalCongruences.append(newCongruences[k]) return crt(finalCongruences) # Returns incongruents solutions to a polynomial congruence def polyCongr(coefficients, m): solutions = [] for i in xrange(m): value = 0 for degree in xrange(len(coefficients)): value += coefficients[degree] * (i ** (len(coefficients) - degree - 1)) if value % m == 0: solutions.append(i) return solutions <|fim▁end|>
crt
<|file_name|>congruences.py<|end_file_name|><|fim▁begin|>import primes as py def lcm(a, b): return a * b / gcd(a, b) def gcd(a, b): while b != 0: (a, b) = (b, a % b) return a # Returns two integers x, y such that gcd(a, b) = ax + by def egcd(a, b): if a == 0: return (0, 1) else: y, x = egcd(b % a, a) return (x - (b // a) * y, y) # Returns an integer x such that ax = 1(mod m) def modInverse(a, m): x, y = egcd(a, m) if gcd(a, m) == 1: return x % m # Reduces linear congruence to form x = b(mod m) def reduceCongr(a, b, m): gcdAB = gcd(a, b) a /= gcdAB b /= gcdAB m /= gcd(gcdAB, m) modinv = modInverse(a, m) b *= modinv return (1, b, m) # Returns the incongruent solutions to the linear congruence ax = b(mod m) def linCongr(a, b, m): solutions = set() if (b % gcd(a, m) == 0): numSols = gcd(a, m) sol = (b * egcd(a, m)[0] / numSols) % m for i in xrange(0, numSols): solutions.add((sol + m * i / numSols) % m) return solutions # Uses the Chinese Remainder Theorem to solve a system of linear congruences def crt(congruences): x = 0 M = 1 for i in xrange(len(congruences)): M *= congruences[i][2] congruences[i] = reduceCongr(congruences[i][0], congruences[i][1], congruences[i][2]) for j in xrange(len(congruences)): m = congruences[j][2] if gcd(m, M/m) != 1: return None x += congruences[j][1] * modInverse(M/m, m) * M / m return x % M # Returns the incongruent solution to any system of linear congruences def <|fim_middle|>(congruences): newCongruences = [] for i in xrange(len(congruences)): congruences[i] = reduceCongr(congruences[i][0], congruences[i][1], congruences[i][2]) # Tests to see whether the system is solvable for j in xrange(len(congruences)): if congruences[i] != congruences[j]: if (congruences[i][1] - congruences[j][1]) % gcd(congruences[i][2], congruences[j][2]) != 0: return None # Splits moduli into prime powers pFactor = py.primeFactorization(congruences[i][2]) for term in pFactor: newCongruences.append((1, congruences[i][1], term[0] ** term[1])) # Discards redundant congruences newCongruences = sorted(newCongruences, key=lambda x: x[2], reverse = True) finalCongruences = [] for k in xrange(len(newCongruences)): isRedundant = False for l in xrange(0, k): if newCongruences[l][2] % newCongruences[k][2] == 0: isRedundant = True if not isRedundant: finalCongruences.append(newCongruences[k]) return crt(finalCongruences) # Returns incongruents solutions to a polynomial congruence def polyCongr(coefficients, m): solutions = [] for i in xrange(m): value = 0 for degree in xrange(len(coefficients)): value += coefficients[degree] * (i ** (len(coefficients) - degree - 1)) if value % m == 0: solutions.append(i) return solutions <|fim▁end|>
linCongrSystem
<|file_name|>congruences.py<|end_file_name|><|fim▁begin|>import primes as py def lcm(a, b): return a * b / gcd(a, b) def gcd(a, b): while b != 0: (a, b) = (b, a % b) return a # Returns two integers x, y such that gcd(a, b) = ax + by def egcd(a, b): if a == 0: return (0, 1) else: y, x = egcd(b % a, a) return (x - (b // a) * y, y) # Returns an integer x such that ax = 1(mod m) def modInverse(a, m): x, y = egcd(a, m) if gcd(a, m) == 1: return x % m # Reduces linear congruence to form x = b(mod m) def reduceCongr(a, b, m): gcdAB = gcd(a, b) a /= gcdAB b /= gcdAB m /= gcd(gcdAB, m) modinv = modInverse(a, m) b *= modinv return (1, b, m) # Returns the incongruent solutions to the linear congruence ax = b(mod m) def linCongr(a, b, m): solutions = set() if (b % gcd(a, m) == 0): numSols = gcd(a, m) sol = (b * egcd(a, m)[0] / numSols) % m for i in xrange(0, numSols): solutions.add((sol + m * i / numSols) % m) return solutions # Uses the Chinese Remainder Theorem to solve a system of linear congruences def crt(congruences): x = 0 M = 1 for i in xrange(len(congruences)): M *= congruences[i][2] congruences[i] = reduceCongr(congruences[i][0], congruences[i][1], congruences[i][2]) for j in xrange(len(congruences)): m = congruences[j][2] if gcd(m, M/m) != 1: return None x += congruences[j][1] * modInverse(M/m, m) * M / m return x % M # Returns the incongruent solution to any system of linear congruences def linCongrSystem(congruences): newCongruences = [] for i in xrange(len(congruences)): congruences[i] = reduceCongr(congruences[i][0], congruences[i][1], congruences[i][2]) # Tests to see whether the system is solvable for j in xrange(len(congruences)): if congruences[i] != congruences[j]: if (congruences[i][1] - congruences[j][1]) % gcd(congruences[i][2], congruences[j][2]) != 0: return None # Splits moduli into prime powers pFactor = py.primeFactorization(congruences[i][2]) for term in pFactor: newCongruences.append((1, congruences[i][1], term[0] ** term[1])) # Discards redundant congruences newCongruences = sorted(newCongruences, key=lambda x: x[2], reverse = True) finalCongruences = [] for k in xrange(len(newCongruences)): isRedundant = False for l in xrange(0, k): if newCongruences[l][2] % newCongruences[k][2] == 0: isRedundant = True if not isRedundant: finalCongruences.append(newCongruences[k]) return crt(finalCongruences) # Returns incongruents solutions to a polynomial congruence def <|fim_middle|>(coefficients, m): solutions = [] for i in xrange(m): value = 0 for degree in xrange(len(coefficients)): value += coefficients[degree] * (i ** (len(coefficients) - degree - 1)) if value % m == 0: solutions.append(i) return solutions <|fim▁end|>
polyCongr
<|file_name|>account_test_classes.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- from odoo.tests.common import HttpCase from odoo.exceptions import ValidationError class AccountingTestCase(HttpCase): """ This class extends the base TransactionCase, in order to test the accounting with localization setups. It is configured to run the tests after the installation of all modules, and will SKIP TESTS ifit cannot find an already configured accounting (which means no localization module has been installed). """ post_install = True at_install = False def setUp(self): super(AccountingTestCase, self).setUp() domain = [('company_id', '=', self.env.ref('base.main_company').id)] if not self.env['account.account'].search_count(domain): self.skipTest("No Chart of account found") def check_complete_move(self, move, theorical_lines): for aml in move.line_ids: line = (aml.name, round(aml.debit, 2), round(aml.credit, 2)) if line in theorical_lines: theorical_lines.remove(line)<|fim▁hole|> return True def ensure_account_property(self, property_name): '''Ensure the ir.property targetting an account.account passed as parameter exists. In case it's not: create it with a random account. This is useful when testing with partially defined localization (missing stock properties for example) :param property_name: The name of the property. ''' company_id = self.env.user.company_id field_id = self.env['ir.model.fields'].search( [('model', '=', 'product.template'), ('name', '=', property_name)], limit=1) property_id = self.env['ir.property'].search([ ('company_id', '=', company_id.id), ('name', '=', property_name), ('res_id', '=', None), ('fields_id', '=', field_id.id)], limit=1) account_id = self.env['account.account'].search([('company_id', '=', company_id.id)], limit=1) value_reference = 'account.account,%d' % account_id.id if property_id and not property_id.value_reference: property_id.value_reference = value_reference else: self.env['ir.property'].create({ 'name': property_name, 'company_id': company_id.id, 'fields_id': field_id.id, 'value_reference': value_reference, })<|fim▁end|>
else: raise ValidationError('Unexpected journal item. (label: %s, debit: %s, credit: %s)' % (aml.name, round(aml.debit, 2), round(aml.credit, 2))) if theorical_lines: raise ValidationError('Remaining theorical line (not found). %s)' % ([(aml[0], aml[1], aml[2]) for aml in theorical_lines]))
<|file_name|>account_test_classes.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- from odoo.tests.common import HttpCase from odoo.exceptions import ValidationError class AccountingTestCase(HttpCase): <|fim_middle|> <|fim▁end|>
""" This class extends the base TransactionCase, in order to test the accounting with localization setups. It is configured to run the tests after the installation of all modules, and will SKIP TESTS ifit cannot find an already configured accounting (which means no localization module has been installed). """ post_install = True at_install = False def setUp(self): super(AccountingTestCase, self).setUp() domain = [('company_id', '=', self.env.ref('base.main_company').id)] if not self.env['account.account'].search_count(domain): self.skipTest("No Chart of account found") def check_complete_move(self, move, theorical_lines): for aml in move.line_ids: line = (aml.name, round(aml.debit, 2), round(aml.credit, 2)) if line in theorical_lines: theorical_lines.remove(line) else: raise ValidationError('Unexpected journal item. (label: %s, debit: %s, credit: %s)' % (aml.name, round(aml.debit, 2), round(aml.credit, 2))) if theorical_lines: raise ValidationError('Remaining theorical line (not found). %s)' % ([(aml[0], aml[1], aml[2]) for aml in theorical_lines])) return True def ensure_account_property(self, property_name): '''Ensure the ir.property targetting an account.account passed as parameter exists. In case it's not: create it with a random account. This is useful when testing with partially defined localization (missing stock properties for example) :param property_name: The name of the property. ''' company_id = self.env.user.company_id field_id = self.env['ir.model.fields'].search( [('model', '=', 'product.template'), ('name', '=', property_name)], limit=1) property_id = self.env['ir.property'].search([ ('company_id', '=', company_id.id), ('name', '=', property_name), ('res_id', '=', None), ('fields_id', '=', field_id.id)], limit=1) account_id = self.env['account.account'].search([('company_id', '=', company_id.id)], limit=1) value_reference = 'account.account,%d' % account_id.id if property_id and not property_id.value_reference: property_id.value_reference = value_reference else: self.env['ir.property'].create({ 'name': property_name, 'company_id': company_id.id, 'fields_id': field_id.id, 'value_reference': value_reference, })
<|file_name|>account_test_classes.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- from odoo.tests.common import HttpCase from odoo.exceptions import ValidationError class AccountingTestCase(HttpCase): """ This class extends the base TransactionCase, in order to test the accounting with localization setups. It is configured to run the tests after the installation of all modules, and will SKIP TESTS ifit cannot find an already configured accounting (which means no localization module has been installed). """ post_install = True at_install = False def setUp(self): <|fim_middle|> def check_complete_move(self, move, theorical_lines): for aml in move.line_ids: line = (aml.name, round(aml.debit, 2), round(aml.credit, 2)) if line in theorical_lines: theorical_lines.remove(line) else: raise ValidationError('Unexpected journal item. (label: %s, debit: %s, credit: %s)' % (aml.name, round(aml.debit, 2), round(aml.credit, 2))) if theorical_lines: raise ValidationError('Remaining theorical line (not found). %s)' % ([(aml[0], aml[1], aml[2]) for aml in theorical_lines])) return True def ensure_account_property(self, property_name): '''Ensure the ir.property targetting an account.account passed as parameter exists. In case it's not: create it with a random account. This is useful when testing with partially defined localization (missing stock properties for example) :param property_name: The name of the property. ''' company_id = self.env.user.company_id field_id = self.env['ir.model.fields'].search( [('model', '=', 'product.template'), ('name', '=', property_name)], limit=1) property_id = self.env['ir.property'].search([ ('company_id', '=', company_id.id), ('name', '=', property_name), ('res_id', '=', None), ('fields_id', '=', field_id.id)], limit=1) account_id = self.env['account.account'].search([('company_id', '=', company_id.id)], limit=1) value_reference = 'account.account,%d' % account_id.id if property_id and not property_id.value_reference: property_id.value_reference = value_reference else: self.env['ir.property'].create({ 'name': property_name, 'company_id': company_id.id, 'fields_id': field_id.id, 'value_reference': value_reference, }) <|fim▁end|>
super(AccountingTestCase, self).setUp() domain = [('company_id', '=', self.env.ref('base.main_company').id)] if not self.env['account.account'].search_count(domain): self.skipTest("No Chart of account found")
<|file_name|>account_test_classes.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- from odoo.tests.common import HttpCase from odoo.exceptions import ValidationError class AccountingTestCase(HttpCase): """ This class extends the base TransactionCase, in order to test the accounting with localization setups. It is configured to run the tests after the installation of all modules, and will SKIP TESTS ifit cannot find an already configured accounting (which means no localization module has been installed). """ post_install = True at_install = False def setUp(self): super(AccountingTestCase, self).setUp() domain = [('company_id', '=', self.env.ref('base.main_company').id)] if not self.env['account.account'].search_count(domain): self.skipTest("No Chart of account found") def check_complete_move(self, move, theorical_lines): <|fim_middle|> def ensure_account_property(self, property_name): '''Ensure the ir.property targetting an account.account passed as parameter exists. In case it's not: create it with a random account. This is useful when testing with partially defined localization (missing stock properties for example) :param property_name: The name of the property. ''' company_id = self.env.user.company_id field_id = self.env['ir.model.fields'].search( [('model', '=', 'product.template'), ('name', '=', property_name)], limit=1) property_id = self.env['ir.property'].search([ ('company_id', '=', company_id.id), ('name', '=', property_name), ('res_id', '=', None), ('fields_id', '=', field_id.id)], limit=1) account_id = self.env['account.account'].search([('company_id', '=', company_id.id)], limit=1) value_reference = 'account.account,%d' % account_id.id if property_id and not property_id.value_reference: property_id.value_reference = value_reference else: self.env['ir.property'].create({ 'name': property_name, 'company_id': company_id.id, 'fields_id': field_id.id, 'value_reference': value_reference, }) <|fim▁end|>
for aml in move.line_ids: line = (aml.name, round(aml.debit, 2), round(aml.credit, 2)) if line in theorical_lines: theorical_lines.remove(line) else: raise ValidationError('Unexpected journal item. (label: %s, debit: %s, credit: %s)' % (aml.name, round(aml.debit, 2), round(aml.credit, 2))) if theorical_lines: raise ValidationError('Remaining theorical line (not found). %s)' % ([(aml[0], aml[1], aml[2]) for aml in theorical_lines])) return True
<|file_name|>account_test_classes.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- from odoo.tests.common import HttpCase from odoo.exceptions import ValidationError class AccountingTestCase(HttpCase): """ This class extends the base TransactionCase, in order to test the accounting with localization setups. It is configured to run the tests after the installation of all modules, and will SKIP TESTS ifit cannot find an already configured accounting (which means no localization module has been installed). """ post_install = True at_install = False def setUp(self): super(AccountingTestCase, self).setUp() domain = [('company_id', '=', self.env.ref('base.main_company').id)] if not self.env['account.account'].search_count(domain): self.skipTest("No Chart of account found") def check_complete_move(self, move, theorical_lines): for aml in move.line_ids: line = (aml.name, round(aml.debit, 2), round(aml.credit, 2)) if line in theorical_lines: theorical_lines.remove(line) else: raise ValidationError('Unexpected journal item. (label: %s, debit: %s, credit: %s)' % (aml.name, round(aml.debit, 2), round(aml.credit, 2))) if theorical_lines: raise ValidationError('Remaining theorical line (not found). %s)' % ([(aml[0], aml[1], aml[2]) for aml in theorical_lines])) return True def ensure_account_property(self, property_name): <|fim_middle|> <|fim▁end|>
'''Ensure the ir.property targetting an account.account passed as parameter exists. In case it's not: create it with a random account. This is useful when testing with partially defined localization (missing stock properties for example) :param property_name: The name of the property. ''' company_id = self.env.user.company_id field_id = self.env['ir.model.fields'].search( [('model', '=', 'product.template'), ('name', '=', property_name)], limit=1) property_id = self.env['ir.property'].search([ ('company_id', '=', company_id.id), ('name', '=', property_name), ('res_id', '=', None), ('fields_id', '=', field_id.id)], limit=1) account_id = self.env['account.account'].search([('company_id', '=', company_id.id)], limit=1) value_reference = 'account.account,%d' % account_id.id if property_id and not property_id.value_reference: property_id.value_reference = value_reference else: self.env['ir.property'].create({ 'name': property_name, 'company_id': company_id.id, 'fields_id': field_id.id, 'value_reference': value_reference, })
<|file_name|>account_test_classes.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- from odoo.tests.common import HttpCase from odoo.exceptions import ValidationError class AccountingTestCase(HttpCase): """ This class extends the base TransactionCase, in order to test the accounting with localization setups. It is configured to run the tests after the installation of all modules, and will SKIP TESTS ifit cannot find an already configured accounting (which means no localization module has been installed). """ post_install = True at_install = False def setUp(self): super(AccountingTestCase, self).setUp() domain = [('company_id', '=', self.env.ref('base.main_company').id)] if not self.env['account.account'].search_count(domain): <|fim_middle|> def check_complete_move(self, move, theorical_lines): for aml in move.line_ids: line = (aml.name, round(aml.debit, 2), round(aml.credit, 2)) if line in theorical_lines: theorical_lines.remove(line) else: raise ValidationError('Unexpected journal item. (label: %s, debit: %s, credit: %s)' % (aml.name, round(aml.debit, 2), round(aml.credit, 2))) if theorical_lines: raise ValidationError('Remaining theorical line (not found). %s)' % ([(aml[0], aml[1], aml[2]) for aml in theorical_lines])) return True def ensure_account_property(self, property_name): '''Ensure the ir.property targetting an account.account passed as parameter exists. In case it's not: create it with a random account. This is useful when testing with partially defined localization (missing stock properties for example) :param property_name: The name of the property. ''' company_id = self.env.user.company_id field_id = self.env['ir.model.fields'].search( [('model', '=', 'product.template'), ('name', '=', property_name)], limit=1) property_id = self.env['ir.property'].search([ ('company_id', '=', company_id.id), ('name', '=', property_name), ('res_id', '=', None), ('fields_id', '=', field_id.id)], limit=1) account_id = self.env['account.account'].search([('company_id', '=', company_id.id)], limit=1) value_reference = 'account.account,%d' % account_id.id if property_id and not property_id.value_reference: property_id.value_reference = value_reference else: self.env['ir.property'].create({ 'name': property_name, 'company_id': company_id.id, 'fields_id': field_id.id, 'value_reference': value_reference, }) <|fim▁end|>
self.skipTest("No Chart of account found")
<|file_name|>account_test_classes.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- from odoo.tests.common import HttpCase from odoo.exceptions import ValidationError class AccountingTestCase(HttpCase): """ This class extends the base TransactionCase, in order to test the accounting with localization setups. It is configured to run the tests after the installation of all modules, and will SKIP TESTS ifit cannot find an already configured accounting (which means no localization module has been installed). """ post_install = True at_install = False def setUp(self): super(AccountingTestCase, self).setUp() domain = [('company_id', '=', self.env.ref('base.main_company').id)] if not self.env['account.account'].search_count(domain): self.skipTest("No Chart of account found") def check_complete_move(self, move, theorical_lines): for aml in move.line_ids: line = (aml.name, round(aml.debit, 2), round(aml.credit, 2)) if line in theorical_lines: <|fim_middle|> else: raise ValidationError('Unexpected journal item. (label: %s, debit: %s, credit: %s)' % (aml.name, round(aml.debit, 2), round(aml.credit, 2))) if theorical_lines: raise ValidationError('Remaining theorical line (not found). %s)' % ([(aml[0], aml[1], aml[2]) for aml in theorical_lines])) return True def ensure_account_property(self, property_name): '''Ensure the ir.property targetting an account.account passed as parameter exists. In case it's not: create it with a random account. This is useful when testing with partially defined localization (missing stock properties for example) :param property_name: The name of the property. ''' company_id = self.env.user.company_id field_id = self.env['ir.model.fields'].search( [('model', '=', 'product.template'), ('name', '=', property_name)], limit=1) property_id = self.env['ir.property'].search([ ('company_id', '=', company_id.id), ('name', '=', property_name), ('res_id', '=', None), ('fields_id', '=', field_id.id)], limit=1) account_id = self.env['account.account'].search([('company_id', '=', company_id.id)], limit=1) value_reference = 'account.account,%d' % account_id.id if property_id and not property_id.value_reference: property_id.value_reference = value_reference else: self.env['ir.property'].create({ 'name': property_name, 'company_id': company_id.id, 'fields_id': field_id.id, 'value_reference': value_reference, }) <|fim▁end|>
theorical_lines.remove(line)
<|file_name|>account_test_classes.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- from odoo.tests.common import HttpCase from odoo.exceptions import ValidationError class AccountingTestCase(HttpCase): """ This class extends the base TransactionCase, in order to test the accounting with localization setups. It is configured to run the tests after the installation of all modules, and will SKIP TESTS ifit cannot find an already configured accounting (which means no localization module has been installed). """ post_install = True at_install = False def setUp(self): super(AccountingTestCase, self).setUp() domain = [('company_id', '=', self.env.ref('base.main_company').id)] if not self.env['account.account'].search_count(domain): self.skipTest("No Chart of account found") def check_complete_move(self, move, theorical_lines): for aml in move.line_ids: line = (aml.name, round(aml.debit, 2), round(aml.credit, 2)) if line in theorical_lines: theorical_lines.remove(line) else: <|fim_middle|> if theorical_lines: raise ValidationError('Remaining theorical line (not found). %s)' % ([(aml[0], aml[1], aml[2]) for aml in theorical_lines])) return True def ensure_account_property(self, property_name): '''Ensure the ir.property targetting an account.account passed as parameter exists. In case it's not: create it with a random account. This is useful when testing with partially defined localization (missing stock properties for example) :param property_name: The name of the property. ''' company_id = self.env.user.company_id field_id = self.env['ir.model.fields'].search( [('model', '=', 'product.template'), ('name', '=', property_name)], limit=1) property_id = self.env['ir.property'].search([ ('company_id', '=', company_id.id), ('name', '=', property_name), ('res_id', '=', None), ('fields_id', '=', field_id.id)], limit=1) account_id = self.env['account.account'].search([('company_id', '=', company_id.id)], limit=1) value_reference = 'account.account,%d' % account_id.id if property_id and not property_id.value_reference: property_id.value_reference = value_reference else: self.env['ir.property'].create({ 'name': property_name, 'company_id': company_id.id, 'fields_id': field_id.id, 'value_reference': value_reference, }) <|fim▁end|>
raise ValidationError('Unexpected journal item. (label: %s, debit: %s, credit: %s)' % (aml.name, round(aml.debit, 2), round(aml.credit, 2)))
<|file_name|>account_test_classes.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- from odoo.tests.common import HttpCase from odoo.exceptions import ValidationError class AccountingTestCase(HttpCase): """ This class extends the base TransactionCase, in order to test the accounting with localization setups. It is configured to run the tests after the installation of all modules, and will SKIP TESTS ifit cannot find an already configured accounting (which means no localization module has been installed). """ post_install = True at_install = False def setUp(self): super(AccountingTestCase, self).setUp() domain = [('company_id', '=', self.env.ref('base.main_company').id)] if not self.env['account.account'].search_count(domain): self.skipTest("No Chart of account found") def check_complete_move(self, move, theorical_lines): for aml in move.line_ids: line = (aml.name, round(aml.debit, 2), round(aml.credit, 2)) if line in theorical_lines: theorical_lines.remove(line) else: raise ValidationError('Unexpected journal item. (label: %s, debit: %s, credit: %s)' % (aml.name, round(aml.debit, 2), round(aml.credit, 2))) if theorical_lines: <|fim_middle|> return True def ensure_account_property(self, property_name): '''Ensure the ir.property targetting an account.account passed as parameter exists. In case it's not: create it with a random account. This is useful when testing with partially defined localization (missing stock properties for example) :param property_name: The name of the property. ''' company_id = self.env.user.company_id field_id = self.env['ir.model.fields'].search( [('model', '=', 'product.template'), ('name', '=', property_name)], limit=1) property_id = self.env['ir.property'].search([ ('company_id', '=', company_id.id), ('name', '=', property_name), ('res_id', '=', None), ('fields_id', '=', field_id.id)], limit=1) account_id = self.env['account.account'].search([('company_id', '=', company_id.id)], limit=1) value_reference = 'account.account,%d' % account_id.id if property_id and not property_id.value_reference: property_id.value_reference = value_reference else: self.env['ir.property'].create({ 'name': property_name, 'company_id': company_id.id, 'fields_id': field_id.id, 'value_reference': value_reference, }) <|fim▁end|>
raise ValidationError('Remaining theorical line (not found). %s)' % ([(aml[0], aml[1], aml[2]) for aml in theorical_lines]))
<|file_name|>account_test_classes.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- from odoo.tests.common import HttpCase from odoo.exceptions import ValidationError class AccountingTestCase(HttpCase): """ This class extends the base TransactionCase, in order to test the accounting with localization setups. It is configured to run the tests after the installation of all modules, and will SKIP TESTS ifit cannot find an already configured accounting (which means no localization module has been installed). """ post_install = True at_install = False def setUp(self): super(AccountingTestCase, self).setUp() domain = [('company_id', '=', self.env.ref('base.main_company').id)] if not self.env['account.account'].search_count(domain): self.skipTest("No Chart of account found") def check_complete_move(self, move, theorical_lines): for aml in move.line_ids: line = (aml.name, round(aml.debit, 2), round(aml.credit, 2)) if line in theorical_lines: theorical_lines.remove(line) else: raise ValidationError('Unexpected journal item. (label: %s, debit: %s, credit: %s)' % (aml.name, round(aml.debit, 2), round(aml.credit, 2))) if theorical_lines: raise ValidationError('Remaining theorical line (not found). %s)' % ([(aml[0], aml[1], aml[2]) for aml in theorical_lines])) return True def ensure_account_property(self, property_name): '''Ensure the ir.property targetting an account.account passed as parameter exists. In case it's not: create it with a random account. This is useful when testing with partially defined localization (missing stock properties for example) :param property_name: The name of the property. ''' company_id = self.env.user.company_id field_id = self.env['ir.model.fields'].search( [('model', '=', 'product.template'), ('name', '=', property_name)], limit=1) property_id = self.env['ir.property'].search([ ('company_id', '=', company_id.id), ('name', '=', property_name), ('res_id', '=', None), ('fields_id', '=', field_id.id)], limit=1) account_id = self.env['account.account'].search([('company_id', '=', company_id.id)], limit=1) value_reference = 'account.account,%d' % account_id.id if property_id and not property_id.value_reference: <|fim_middle|> else: self.env['ir.property'].create({ 'name': property_name, 'company_id': company_id.id, 'fields_id': field_id.id, 'value_reference': value_reference, }) <|fim▁end|>
property_id.value_reference = value_reference
<|file_name|>account_test_classes.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- from odoo.tests.common import HttpCase from odoo.exceptions import ValidationError class AccountingTestCase(HttpCase): """ This class extends the base TransactionCase, in order to test the accounting with localization setups. It is configured to run the tests after the installation of all modules, and will SKIP TESTS ifit cannot find an already configured accounting (which means no localization module has been installed). """ post_install = True at_install = False def setUp(self): super(AccountingTestCase, self).setUp() domain = [('company_id', '=', self.env.ref('base.main_company').id)] if not self.env['account.account'].search_count(domain): self.skipTest("No Chart of account found") def check_complete_move(self, move, theorical_lines): for aml in move.line_ids: line = (aml.name, round(aml.debit, 2), round(aml.credit, 2)) if line in theorical_lines: theorical_lines.remove(line) else: raise ValidationError('Unexpected journal item. (label: %s, debit: %s, credit: %s)' % (aml.name, round(aml.debit, 2), round(aml.credit, 2))) if theorical_lines: raise ValidationError('Remaining theorical line (not found). %s)' % ([(aml[0], aml[1], aml[2]) for aml in theorical_lines])) return True def ensure_account_property(self, property_name): '''Ensure the ir.property targetting an account.account passed as parameter exists. In case it's not: create it with a random account. This is useful when testing with partially defined localization (missing stock properties for example) :param property_name: The name of the property. ''' company_id = self.env.user.company_id field_id = self.env['ir.model.fields'].search( [('model', '=', 'product.template'), ('name', '=', property_name)], limit=1) property_id = self.env['ir.property'].search([ ('company_id', '=', company_id.id), ('name', '=', property_name), ('res_id', '=', None), ('fields_id', '=', field_id.id)], limit=1) account_id = self.env['account.account'].search([('company_id', '=', company_id.id)], limit=1) value_reference = 'account.account,%d' % account_id.id if property_id and not property_id.value_reference: property_id.value_reference = value_reference else: <|fim_middle|> <|fim▁end|>
self.env['ir.property'].create({ 'name': property_name, 'company_id': company_id.id, 'fields_id': field_id.id, 'value_reference': value_reference, })
<|file_name|>account_test_classes.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- from odoo.tests.common import HttpCase from odoo.exceptions import ValidationError class AccountingTestCase(HttpCase): """ This class extends the base TransactionCase, in order to test the accounting with localization setups. It is configured to run the tests after the installation of all modules, and will SKIP TESTS ifit cannot find an already configured accounting (which means no localization module has been installed). """ post_install = True at_install = False def <|fim_middle|>(self): super(AccountingTestCase, self).setUp() domain = [('company_id', '=', self.env.ref('base.main_company').id)] if not self.env['account.account'].search_count(domain): self.skipTest("No Chart of account found") def check_complete_move(self, move, theorical_lines): for aml in move.line_ids: line = (aml.name, round(aml.debit, 2), round(aml.credit, 2)) if line in theorical_lines: theorical_lines.remove(line) else: raise ValidationError('Unexpected journal item. (label: %s, debit: %s, credit: %s)' % (aml.name, round(aml.debit, 2), round(aml.credit, 2))) if theorical_lines: raise ValidationError('Remaining theorical line (not found). %s)' % ([(aml[0], aml[1], aml[2]) for aml in theorical_lines])) return True def ensure_account_property(self, property_name): '''Ensure the ir.property targetting an account.account passed as parameter exists. In case it's not: create it with a random account. This is useful when testing with partially defined localization (missing stock properties for example) :param property_name: The name of the property. ''' company_id = self.env.user.company_id field_id = self.env['ir.model.fields'].search( [('model', '=', 'product.template'), ('name', '=', property_name)], limit=1) property_id = self.env['ir.property'].search([ ('company_id', '=', company_id.id), ('name', '=', property_name), ('res_id', '=', None), ('fields_id', '=', field_id.id)], limit=1) account_id = self.env['account.account'].search([('company_id', '=', company_id.id)], limit=1) value_reference = 'account.account,%d' % account_id.id if property_id and not property_id.value_reference: property_id.value_reference = value_reference else: self.env['ir.property'].create({ 'name': property_name, 'company_id': company_id.id, 'fields_id': field_id.id, 'value_reference': value_reference, }) <|fim▁end|>
setUp
<|file_name|>account_test_classes.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- from odoo.tests.common import HttpCase from odoo.exceptions import ValidationError class AccountingTestCase(HttpCase): """ This class extends the base TransactionCase, in order to test the accounting with localization setups. It is configured to run the tests after the installation of all modules, and will SKIP TESTS ifit cannot find an already configured accounting (which means no localization module has been installed). """ post_install = True at_install = False def setUp(self): super(AccountingTestCase, self).setUp() domain = [('company_id', '=', self.env.ref('base.main_company').id)] if not self.env['account.account'].search_count(domain): self.skipTest("No Chart of account found") def <|fim_middle|>(self, move, theorical_lines): for aml in move.line_ids: line = (aml.name, round(aml.debit, 2), round(aml.credit, 2)) if line in theorical_lines: theorical_lines.remove(line) else: raise ValidationError('Unexpected journal item. (label: %s, debit: %s, credit: %s)' % (aml.name, round(aml.debit, 2), round(aml.credit, 2))) if theorical_lines: raise ValidationError('Remaining theorical line (not found). %s)' % ([(aml[0], aml[1], aml[2]) for aml in theorical_lines])) return True def ensure_account_property(self, property_name): '''Ensure the ir.property targetting an account.account passed as parameter exists. In case it's not: create it with a random account. This is useful when testing with partially defined localization (missing stock properties for example) :param property_name: The name of the property. ''' company_id = self.env.user.company_id field_id = self.env['ir.model.fields'].search( [('model', '=', 'product.template'), ('name', '=', property_name)], limit=1) property_id = self.env['ir.property'].search([ ('company_id', '=', company_id.id), ('name', '=', property_name), ('res_id', '=', None), ('fields_id', '=', field_id.id)], limit=1) account_id = self.env['account.account'].search([('company_id', '=', company_id.id)], limit=1) value_reference = 'account.account,%d' % account_id.id if property_id and not property_id.value_reference: property_id.value_reference = value_reference else: self.env['ir.property'].create({ 'name': property_name, 'company_id': company_id.id, 'fields_id': field_id.id, 'value_reference': value_reference, }) <|fim▁end|>
check_complete_move
<|file_name|>account_test_classes.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- from odoo.tests.common import HttpCase from odoo.exceptions import ValidationError class AccountingTestCase(HttpCase): """ This class extends the base TransactionCase, in order to test the accounting with localization setups. It is configured to run the tests after the installation of all modules, and will SKIP TESTS ifit cannot find an already configured accounting (which means no localization module has been installed). """ post_install = True at_install = False def setUp(self): super(AccountingTestCase, self).setUp() domain = [('company_id', '=', self.env.ref('base.main_company').id)] if not self.env['account.account'].search_count(domain): self.skipTest("No Chart of account found") def check_complete_move(self, move, theorical_lines): for aml in move.line_ids: line = (aml.name, round(aml.debit, 2), round(aml.credit, 2)) if line in theorical_lines: theorical_lines.remove(line) else: raise ValidationError('Unexpected journal item. (label: %s, debit: %s, credit: %s)' % (aml.name, round(aml.debit, 2), round(aml.credit, 2))) if theorical_lines: raise ValidationError('Remaining theorical line (not found). %s)' % ([(aml[0], aml[1], aml[2]) for aml in theorical_lines])) return True def <|fim_middle|>(self, property_name): '''Ensure the ir.property targetting an account.account passed as parameter exists. In case it's not: create it with a random account. This is useful when testing with partially defined localization (missing stock properties for example) :param property_name: The name of the property. ''' company_id = self.env.user.company_id field_id = self.env['ir.model.fields'].search( [('model', '=', 'product.template'), ('name', '=', property_name)], limit=1) property_id = self.env['ir.property'].search([ ('company_id', '=', company_id.id), ('name', '=', property_name), ('res_id', '=', None), ('fields_id', '=', field_id.id)], limit=1) account_id = self.env['account.account'].search([('company_id', '=', company_id.id)], limit=1) value_reference = 'account.account,%d' % account_id.id if property_id and not property_id.value_reference: property_id.value_reference = value_reference else: self.env['ir.property'].create({ 'name': property_name, 'company_id': company_id.id, 'fields_id': field_id.id, 'value_reference': value_reference, }) <|fim▁end|>
ensure_account_property
<|file_name|>SubusersGetRequest.py<|end_file_name|><|fim▁begin|>''' Created by auto_sdk on 2014-12-17 17:22:51 ''' from top.api.base import RestApi class SubusersGetRequest(RestApi): def __init__(self,domain='gw.api.taobao.com',port=80): RestApi.__init__(self,domain, port) self.user_nick = None <|fim▁hole|> return 'taobao.subusers.get'<|fim▁end|>
def getapiname(self):
<|file_name|>SubusersGetRequest.py<|end_file_name|><|fim▁begin|>''' Created by auto_sdk on 2014-12-17 17:22:51 ''' from top.api.base import RestApi class SubusersGetRequest(RestApi): <|fim_middle|> <|fim▁end|>
def __init__(self,domain='gw.api.taobao.com',port=80): RestApi.__init__(self,domain, port) self.user_nick = None def getapiname(self): return 'taobao.subusers.get'
<|file_name|>SubusersGetRequest.py<|end_file_name|><|fim▁begin|>''' Created by auto_sdk on 2014-12-17 17:22:51 ''' from top.api.base import RestApi class SubusersGetRequest(RestApi): def __init__(self,domain='gw.api.taobao.com',port=80): <|fim_middle|> def getapiname(self): return 'taobao.subusers.get' <|fim▁end|>
RestApi.__init__(self,domain, port) self.user_nick = None
<|file_name|>SubusersGetRequest.py<|end_file_name|><|fim▁begin|>''' Created by auto_sdk on 2014-12-17 17:22:51 ''' from top.api.base import RestApi class SubusersGetRequest(RestApi): def __init__(self,domain='gw.api.taobao.com',port=80): RestApi.__init__(self,domain, port) self.user_nick = None def getapiname(self): <|fim_middle|> <|fim▁end|>
return 'taobao.subusers.get'
<|file_name|>SubusersGetRequest.py<|end_file_name|><|fim▁begin|>''' Created by auto_sdk on 2014-12-17 17:22:51 ''' from top.api.base import RestApi class SubusersGetRequest(RestApi): def <|fim_middle|>(self,domain='gw.api.taobao.com',port=80): RestApi.__init__(self,domain, port) self.user_nick = None def getapiname(self): return 'taobao.subusers.get' <|fim▁end|>
__init__
<|file_name|>SubusersGetRequest.py<|end_file_name|><|fim▁begin|>''' Created by auto_sdk on 2014-12-17 17:22:51 ''' from top.api.base import RestApi class SubusersGetRequest(RestApi): def __init__(self,domain='gw.api.taobao.com',port=80): RestApi.__init__(self,domain, port) self.user_nick = None def <|fim_middle|>(self): return 'taobao.subusers.get' <|fim▁end|>
getapiname