Search is not available for this dataset
text stringlengths 75 104k |
|---|
def finish(self):
"""
Finish the decompressor. As the decompressor decompresses eagerly, this
will never actually emit any data. However, it will potentially throw
errors if a truncated or damaged data stream has been used.
Note that, once this method is called, the decompressor... |
def hsv_to_rgb(hsv):
"""Converts a tuple of hue, saturation, value to a tuple of red, green blue.
Hue should be an angle from 0.0 to 359.0. Saturation and value should be a
value from 0.0 to 1.0, where saturation controls the intensity of the hue and
value controls the brightness.
"""
# Algorit... |
def set_cursor(self, col, row):
"""Move the cursor to an explicit column and row position."""
# Clamp row to the last row of the display.
if row > self._lines:
row = self._lines - 1
# Set location.
self.write8(LCD_SETDDRAMADDR | (col + LCD_ROW_OFFSETS[row])) |
def enable_display(self, enable):
"""Enable or disable the display. Set enable to True to enable."""
if enable:
self.displaycontrol |= LCD_DISPLAYON
else:
self.displaycontrol &= ~LCD_DISPLAYON
self.write8(LCD_DISPLAYCONTROL | self.displaycontrol) |
def show_cursor(self, show):
"""Show or hide the cursor. Cursor is shown if show is True."""
if show:
self.displaycontrol |= LCD_CURSORON
else:
self.displaycontrol &= ~LCD_CURSORON
self.write8(LCD_DISPLAYCONTROL | self.displaycontrol) |
def blink(self, blink):
"""Turn on or off cursor blinking. Set blink to True to enable blinking."""
if blink:
self.displaycontrol |= LCD_BLINKON
else:
self.displaycontrol &= ~LCD_BLINKON
self.write8(LCD_DISPLAYCONTROL | self.displaycontrol) |
def set_left_to_right(self):
"""Set text direction left to right."""
self.displaymode |= LCD_ENTRYLEFT
self.write8(LCD_ENTRYMODESET | self.displaymode) |
def set_right_to_left(self):
"""Set text direction right to left."""
self.displaymode &= ~LCD_ENTRYLEFT
self.write8(LCD_ENTRYMODESET | self.displaymode) |
def autoscroll(self, autoscroll):
"""Autoscroll will 'right justify' text from the cursor if set True,
otherwise it will 'left justify' the text.
"""
if autoscroll:
self.displaymode |= LCD_ENTRYSHIFTINCREMENT
else:
self.displaymode &= ~LCD_ENTRYSHIFTINCREM... |
def message(self, text):
"""Write text to display. Note that text can include newlines."""
line = 0
# Iterate through each character.
for char in text:
# Advance to next line if character is a new line.
if char == '\n':
line += 1
#... |
def set_backlight(self, backlight):
"""Enable or disable the backlight. If PWM is not enabled (default), a
non-zero backlight value will turn on the backlight and a zero value will
turn it off. If PWM is enabled, backlight can be any value from 0.0 to
1.0, with 1.0 being full intensity... |
def write8(self, value, char_mode=False):
"""Write 8-bit value in character or data mode. Value should be an int
value from 0-255, and char_mode is True if character data or False if
non-character data (default).
"""
# One millisecond delay to prevent writing too quickly.
... |
def create_char(self, location, pattern):
"""Fill one of the first 8 CGRAM locations with custom characters.
The location parameter should be between 0 and 7 and pattern should
provide an array of 8 bytes containing the pattern. E.g. you can easyly
design your custom character at http://... |
def set_color(self, red, green, blue):
"""Set backlight color to provided red, green, and blue values. If PWM
is enabled then color components can be values from 0.0 to 1.0, otherwise
components should be zero for off and non-zero for on.
"""
if self._pwm_enabled:
# ... |
def is_pressed(self, button):
"""Return True if the provided button is pressed, False otherwise."""
if button not in set((SELECT, RIGHT, DOWN, UP, LEFT)):
raise ValueError('Unknown button, must be SELECT, RIGHT, DOWN, UP, or LEFT.')
return self._mcp.input(button) == GPIO.LOW |
def getResults(self, parFound = None):
'''
Function to obtain the Dictionarythat represents this object.
:param parFound: values to return.
:return: The output format will be like:
[{"type" : "i3visio.email", "value": "foo@bar.com", "attri... |
def findExp(self, data):
'''
Method to look for the current regular expression in the provided string.
:param data: string containing the text where the expressions will be looked for.
:return: a list of verified regular expressions.
'''
temp = []
... |
def checkPhoneDetails(query=None):
'''
Method that checks if the given hash is stored in the md5crack.com website.
:param query: query to verify.
:return: Python structure.
'''
results = []
#TO-DO executing the query against Google and grab the results
# The... |
def exportUsufy(data, ext, fileH):
"""
Method that exports the different structures onto different formats.
Args:
-----
data: Data to export.
ext: One of the following: csv, excel, json, ods.
fileH: Fileheader for the output files.
Returns:
--------
Performs the... |
def _generateTabularData(res, oldTabularData = {}, isTerminal=False, canUnicode=True):
"""
Method that recovers the values and columns from the current structure
This method is used by:
- usufyToCsvExport
- usufyToOdsExport
- usufyToXlsExport
- usufyToXlsxExport
Args:
... |
def usufyToJsonExport(d, fPath):
"""
Workaround to export to a json file.
Args:
-----
d: Data to export.
fPath: File path for the output file.
"""
oldData = []
try:
with open (fPath) as iF:
oldText = iF.read()
if oldText != "":
... |
def usufyToTextExport(d, fPath=None):
"""
Workaround to export to a .txt file or to show the information.
Args:
-----
d: Data to export.
fPath: File path for the output file. If None was provided, it will
assume that it has to print it.
Returns:
--------
uni... |
def usufyToCsvExport(d, fPath):
"""
Workaround to export to a CSV file.
Args:
-----
d: Data to export.
fPath: File path for the output file.
"""
from pyexcel_io import get_data
try:
oldData = {"OSRFramework": get_data(fPath) }
except:
# No information ha... |
def usufyToOdsExport(d, fPath):
"""
Workaround to export to a .ods file.
Args:
-----
d: Data to export.
fPath: File path for the output file.
"""
from pyexcel_ods import get_data
try:
#oldData = get_data(fPath)
# A change in the API now returns only an array ... |
def usufyToXlsExport(d, fPath):
"""
Workaround to export to a .xls file.
Args:
-----
d: Data to export.
fPath: File path for the output file.
"""
from pyexcel_xls import get_data
try:
#oldData = get_data(fPath)
# A change in the API now returns only an array ... |
def usufyToXlsxExport(d, fPath):
"""
Workaround to export to a .xlsx file.
Args:
-----
d: Data to export.
fPath: File path for the output file.
"""
from pyexcel_xlsx import get_data
try:
#oldData = get_data(fPath)
# A change in the API now returns only an arr... |
def _generateGraphData(data, oldData=nx.Graph()):
"""
Processing the data from i3visio structures to generate nodes and edges
This function uses the networkx graph library. It will create a new node
for each and i3visio.<something> entities while it will add properties for
all the attribute startin... |
def usufyToGmlExport(d, fPath):
"""
Workaround to export data to a .gml file.
Args:
-----
d: Data to export.
fPath: File path for the output file.
"""
# Reading the previous gml file
try:
oldData=nx.read_gml(fPath)
except UnicodeDecodeError as e:
print("U... |
def usufyToPngExport(d, fPath):
"""
Workaround to export to a png file.
Args:
-----
d: Data to export.
fPath: File path for the output file.
"""
newGraph = _generateGraphData(d)
import matplotlib.pyplot as plt
# Writing the png file
nx.draw(newGraph)
plt.savefig... |
def fileToMD5(filename, block_size=256*128, binary=False):
"""
A function that calculates the MD5 hash of a file.
Args:
-----
filename: Path to the file.
block_size: Chunks of suitable size. Block size directly depends on
the block size of your filesystem to avoid performanc... |
def getCurrentStrDatetime():
"""
Generating the current Datetime with a given format
Returns:
--------
string: The string of a date.
"""
# Generating current time
i = datetime.datetime.now()
strTime = "%s-%s-%s_%sh%sm" % (i.year, i.month, i.day, i.hour, i.minute)
return strT... |
def getFilesFromAFolder(path):
"""
Getting all the files in a folder.
Args:
-----
path: The path in which looking for the files
Returns:
--------
list: The list of filenames found.
"""
from os import listdir
from os.path import isfile, join
#onlyfiles = [ f for ... |
def urisToBrowser(uris=[], autoraise=True):
"""
Method that launches the URI in the default browser of the system
This function temporally deactivates the standard ouptut and errors to
prevent the system to show unwanted messages. This method is based on this
question from Stackoverflow.
https:... |
def openResultsInBrowser(res):
"""
Method that collects the URI from a list of entities and opens them
Args:
-----
res: A list containing several i3visio entities.
"""
print(emphasis("\n\tOpening URIs in the default web browser..."))
urisToBrowser(["https://github.com/i3visio/osrfr... |
def colorize(text, messageType=None):
"""
Function that colorizes a message.
Args:
-----
text: The string to be colorized.
messageType: Possible options include "ERROR", "WARNING", "SUCCESS",
"INFO" or "BOLD".
Returns:
--------
string: Colorized if the optio... |
def showLicense():
"""
Method that prints the license if requested.
It tries to find the license online and manually download it. This method
only prints its contents in plain text.
"""
print("Trying to recover the contents of the license...\n")
try:
# Grab the license online and pr... |
def expandEntitiesFromEmail(e):
"""
Method that receives an email an creates linked entities
Args:
-----
e: Email to verify.
Returns:
--------
Three different values: email, alias and domain in a list.
"""
# Grabbing the email
email = {}
email["type"] = "i3vis... |
def getNumberTLD():
"""
Counting the total number of TLD being processed.
"""
total = 0
for typeTld in TLD.keys():
total+= len(TLD[typeTld])
return total |
def getWhoisInfo(domain):
"""
Method that trie to recover the whois info from a domain.
Args:
-----
domain: The domain to verify.
Returns:
--------
dict: A dictionary containing the result as an i3visio entity with its
`value`, `type` and `attributes`.
"""
n... |
def createDomains(tlds, nicks=None, nicksFile=None):
"""
Method that globally permits to generate the domains to be checked.
Args:
-----
tlds: List of tlds.
nicks: List of aliases.
nicksFile: The filepath to the aliases file.
Returns:
--------
list: list of doma... |
def pool_function(domain, launchWhois=False):
"""
Wrapper for being able to launch all the threads of getPageWrapper.
Args:
-----
domain: We receive the parameters as a dictionary.
```
{
"domain" : ".com",
"type" : "global"
}
```
l... |
def performSearch(domains=[], nThreads=16, launchWhois=False):
"""
Method to perform the mail verification process.
Arguments
---------
domains: List of domains to check.
nThreads: Number of threads to use.
launchWhois: Sets if whois queries will be launched.
Returns
--... |
def main(params=None):
"""
Main function to launch phonefy.
The function is created in this way so as to let other applications make
use of the full configuration capabilities of the application. The
parameters received are used as parsed by this modules `getParser()`.
Args:
-----
... |
def getEntitiesByRegexp(data = None, listRegexp = None, verbosity=1, logFolder="./logs"):
"""
Method to obtain entities by Regexp.
Args:
-----
data: text where the entities will be looked for.
listRegexp: list of selected regular expressions to be looked for. If
None was pro... |
def scanFolderForRegexp(folder = None, listRegexp = None, recursive = False, verbosity=1, logFolder= "./logs", quiet=False):
"""
[Optionally] recursive method to scan the files in a given folder.
Args:
-----
folder: the folder to be scanned.
listRegexp: listRegexp is an array of <Regexp... |
def scanResource(uri = None, listRegexp = None, verbosity=1, logFolder= "./logs"):
"""
[Optionally] recursive method to scan the files in a given folder.
Args:
-----
uri: the URI to be scanned.
listRegexp: listRegexp is an array of <RegexpObject>.
Returns:
-------
dict:... |
def main(params=None):
"""
Main function to launch phonefy.
The function is created in this way so as to let other applications make
use of the full configuration capabilities of the application. The
parameters received are used as parsed by this modules `getParser()`.
Args:
-----
... |
def checkIpDetails(query=None):
'''
Method that checks if the given hash is stored in the md5crack.com website. An example of the json received:
{
"as": "AS8560 1\u00261 Internet AG",
"city": "",
"country": "Germany",
"countryCode": "DE",
... |
def check_mailfy(self, query, kwargs={}):
"""
Verifying a mailfy query in this platform.
This might be redefined in any class inheriting from Platform. The only
condition is that any of this should return a dictionary as defined.
Args:
-----
query: The eleme... |
def weCanCheckTheseDomains(email):
"""
Method that verifies if a domain can be safely verified.
Args:
-----
email: the email whose domain will be verified.
Returns:
--------
bool: it represents whether the domain can be verified.
"""
# Known platform not to be working..... |
def grabEmails(emails=None, emailsFile=None, nicks=None, nicksFile=None, domains=EMAIL_DOMAINS, excludeDomains=[]):
"""
Method that generates a list of emails.
Args:
-----
emails: Any premade list of emails.
emailsFile: Filepath to the emails file (one per line).
nicks: A list o... |
def processMailList(platformNames=[], emails=[]):
"""
Method to perform the email search.
Args:
-----
platformNames: List of names of the platforms.
emails: List of numbers to be queried.
Return:
-------
A list of verified emails.
"""
# Grabbing the <Platform> o... |
def pool_function(args):
"""
A wrapper for being able to launch all the threads.
We will use python-emailahoy library for the verification.
Args:
-----
args: reception of the parameters for getPageWrapper as a tuple.
Returns:
--------
A dictionary representing whether the ... |
def performSearch(emails=[], nThreads=16, secondsBeforeTimeout=5):
"""
Method to perform the mail verification process.
Args:
-----
emails: list of emails to be verified.
platforms: list of strings representing the wrappers to be used.
nThreads: the number of threads to be used.... |
def main(params=None):
"""
Main function to launch phonefy.
The function is created in this way so as to let other applications make
use of the full configuration capabilities of the application. The
parameters received are used as parsed by this modules `getParser()`.
Args:
-----
... |
def recoverURL(self, url):
"""
Public method to recover a resource.
Args:
-----
url: The URL to be collected.
Returns:
--------
Returns a resource that has to be read, for instance, with html = self.br.read()
"""
# Configuring use... |
def setNewPassword(self, url, username, password):
"""
Public method to manually set the credentials for a url in the browser.
"""
self.br.add_password(url, username, password) |
def setProxy(self, protocol="http"):
"""
Public method to set a proxy for the browser.
"""
# Setting proxy
try:
new = { protocol: self.proxies[protocol]}
self.br.set_proxies( new )
except:
# No proxy defined for that protocol
... |
def setUserAgent(self, uA=None):
"""
This method will be called whenever a new query will be executed.
:param uA: Any User Agent that was needed to be inserted. This parameter is optional.
:return: Returns True if a User Agent was inserted and False if no User Agent c... |
def main(params=None):
"""
Main function to launch OSRFramework CLI
The function is created in this way so as to let other applications make
use of the full configuration capabilities of the application. The
parameters received are used as parsed by this modules `getParser()`.
Args:
... |
def main(args):
"""
Query manager.
"""
# Creating the instance
tAW = TwitterAPIWrapper()
# Selecting the query to be launched
if args.type == "get_all_docs":
results = tAW.get_all_docs(args.query)
elif args.type == "get_user":
results = tAW.get_user(args.query)
... |
def _connectToAPI(self):
"""
:return: A tweepy.API object that performs the queries
"""
#authorize twitter, initialize tweepy
auth = tweepy.OAuthHandler(self.consumer_key, self.consumer_secret)
auth.set_access_token(self.access_key, self.access_secret)
api = t... |
def _rate_limit_status(self, api=None, mode=None):
"""
Verifying the API limits
"""
if api == None:
api = self.connectToAPI()
if mode == None:
print json.dumps(api.rate_limit_status(), indent=2)
raw_input("<Press ENTER>")
else:
... |
def _processUser(self, jUser):
"""
Convert tweepy.User to a i3visio-like user. This will process the returned JSON object that the API returns to transform it to the i3visio-like format. A sample answer is copied now when testing it to the @i3visio user in Twitter.
{
"follow_request_sent": false,
... |
def get_all_docs(self, screen_name):
"""
Method to get all the tweets emitted by a user.
:param screen_name: The Twitter username.
:return: List of tweets.
"""
def _getNewTweets(api, screen_name,count=200, oldest=None, waitTime=60):
"""
... |
def get_followers(self, query):
"""
Method to get the followers of a user.
:param query: Query to be performed.
:return: List of ids.
"""
# Connecting to the API
api = self._connectToAPI()
# Verifying the limits of the API
self.... |
def get_friends(self, query):
"""
Method to get the friends of a user.
:param query: Query to be performed.
:return: List of users.
"""
# Connecting to the API
api = self._connectToAPI()
# Verifying the limits of the API
self._r... |
def get_user(self, screen_name):
"""
Method to perform the usufy searches.
:param screen_name: nickname to be searched.
:return: User.
"""
# Connecting to the API
api = self._connectToAPI()
# Verifying the limits of the API
self._... |
def search_users(self, query, n=20, maxUsers=60):
"""
Method to perform the searchfy searches.
:param query: Query to be performed.
:param n: Number of results per query.
:param maxUsers: Max. number of users to be recovered.
:return: List ... |
def validate_categories(categories):
"""Take an iterable of source categories and raise ValueError if some
of them are invalid."""
if not set(categories) <= Source.categories:
invalid = list(set(categories) - Source.categories)
raise ValueError('Invalid categories: %s' %... |
def checkIfHashIsCracked(hash=None):
"""
Method that checks if the given hash is stored in the md5db.net website.
:param hash: hash to verify.
:return: Resolved hash. If nothing was found, it will return an empty list.
"""
apiURL = "http://md5db.net/api/" + str(hash).lower()
try:
# Getting the result ... |
def fuzzUsufy(fDomains = None, fFuzzStruct = None):
"""
Method to guess the usufy path against a list of domains or subdomains.
Args:
-----
fDomains: A list to strings containing the domains and (optionally) a
nick.
fFuzzStruct: A list to strings containing the transforms to... |
def pool_function(p, nick, rutaDescarga, avoidProcessing=True, avoidDownload=True, verbosity=1):
"""
Wrapper for being able to launch all the threads of getPageWrapper.
We receive the parameters for getPageWrapper as a tuple.
Args:
-----
pName: Platform where the information is stored. It ... |
def processNickList(nicks, platforms=None, rutaDescarga="./", avoidProcessing=True, avoidDownload=True, nThreads=12, verbosity=1, logFolder="./logs"):
"""
Process a list of nicks to check whether they exist.
This method receives as a parameter a series of nicks and verifies whether
those nicks have a p... |
def main(params=None):
"""
Main function to launch usufy.
The function is created in this way so as to let other applications make
use of the full configuration capabilities of the application. The
parameters received are used as parsed by this modules `getParser()`.
Args:
-----
pa... |
def generate(name=None, surname1=None, surname2=None, city=None, country=None, year=None, useNumbers=False, useCommonWords=False, useLeet=False, useLocales=False, extraWords=[]):
"""
The method that generates the given aliases.
It receives several parameters as parsed by this module's `getParser()`.
Pr... |
def main(params=None):
"""
Main function to launch alias_generator.
Args:
-----
params: A list with the parameters as grabbed by the terminal. It is
None when this is called by an entry_point. If it is called by osrf
the data is already parsed.
"""
if params == N... |
def _prepare_filtering_params(domain=None, category=None,
sponsored_source=None, has_field=None,
has_fields=None, query_params_match=None,
query_person_match=None, **kwargs):
"""Transform the params to th... |
def add_records_filter(self, domain=None, category=None,
sponsored_source=None, has_fields=None,
query_params_match=None, query_person_match=None):
"""Add a new "and" filter for the records returned in the response.
IMPORTANT: This me... |
def append_priority_rule(self, domain=None, category=None,
sponsored_source=None, has_field=None,
query_params_match=None, query_person_match=None):
"""Append a new priority rule for the records returned in the response.
IMPORTANT... |
def validate_query_params(self, strict=True):
"""Check if the request is valid and can be sent, raise ValueError if
not.
`strict` is a boolean argument that defaults to True which means an
exception is raised on every invalid query parameter, if set to False
an e... |
def url(self):
"""The URL of the request (str)."""
query = {
'key': self.api_key or default_api_key,
'person': self.person.to_json(),
'query_params_mode': self.query_params_mode,
'exact_name': self.exact_name,
'prioritize_records_by': ',... |
def send(self, strict_validation=True):
"""Send the request and return the response or raise SearchAPIError.
Calling this method blocks the program until the response is returned,
if you want the request to be sent asynchronously please refer to the
send_async method.
... |
def send_async(self, callback, strict_validation=True):
"""Same as send() but in a non-blocking way.
Use this method if you want to send the request asynchronously so your
program can do other things while waiting for the response.
`callback` is a function (or ot... |
def group_records(self, key_function):
"""Return a dict with the records grouped by the key returned by
`key_function`.
`key_function` takes a record and returns the value from the record to
group by (see examples in the group_records_by_* methods below).
... |
def group_records_by_domain(self):
"""Return the records grouped by the domain they came from.
The return value is a dict, a key in this dict is a domain
and the value is a list of all the records with this domain.
"""
key_function = lambda record: record... |
def group_records_by_category(self):
"""Return the records grouped by the category of their source.
The return value is a dict, a key in this dict is a category
and the value is a list of all the records with this category.
"""
Source.validate_categories(... |
def from_dict(d):
"""Transform the dict to a response object and return the response."""
warnings_ = d.get('warnings', [])
query = d.get('query') or None
if query:
query = Person.from_dict(query)
person = d.get('person') or None
if person:
... |
def to_dict(self):
"""Return a dict representation of the response."""
d = {}
if self.warnings:
d['warnings'] = self.warnings
if self.query is not None:
d['query'] = self.query.to_dict()
if self.person is not None:
d['person'] = self.pe... |
def validate_type(self, type_):
"""Take an str/unicode `type_` and raise a ValueError if it's not
a valid type for the object.
A valid type for a field is a value from the types_set attribute of
that field's class.
"""
if type_ is not None and... |
def from_dict(cls, d):
"""Transform the dict to a field object and return the field."""
kwargs = {}
for key, val in d.iteritems():
if key.startswith('display'): # includes phone.display_international
continue
if key.startswith('@'):
... |
def to_dict(self):
"""Return a dict representation of the field."""
d = {}
if self.valid_since is not None:
d['@valid_since'] = datetime_to_str(self.valid_since)
for attr_list, prefix in [(self.attributes, '@'), (self.children, '')]:
for attr in attr_list:
... |
def is_searchable(self):
"""A bool value that indicates whether the name is a valid name to
search by."""
first = alpha_chars(self.first or u'')
last = alpha_chars(self.last or u'')
raw = alpha_chars(self.raw or u'')
return (len(first) >= 2 and len(last) >= 2) or l... |
def display(self):
"""A unicode value with the object's data, to be used for displaying
the object in your application."""
country = self.country if self.state else self.country_full
state = self.state if self.city else self.state_full
vals = (self.street, self.city, state,... |
def is_searchable(self):
"""A bool value that indicates whether the address is a valid address
to search by."""
return self.raw or (self.is_valid_country and
(not self.state or self.is_valid_state)) |
def is_valid_state(self):
"""A bool value that indicates whether the object's state is a valid
state code."""
return self.is_valid_country and self.country.upper() in STATES and \
self.state is not None and \
self.state.upper() in STATES[self.country.upper()] |
def state_full(self):
"""unicode, the full name of the object's state.
>>> address = Address(country='US', state='CO')
>>> address.state
u'CO'
>>> address.state_full
u'Colorado'
"""
if self.is_valid_state:
ret... |
def from_text(text):
"""Strip `text` (unicode/str) from all non-digit chars and return a new
Phone object with the number from text.
>>> phone = Phone.from_text('(888) 777-666')
>>> phone.number
888777666
"""
number = int(filter(unicode.... |
def from_dict(cls, d):
"""Extend Field.from_dict, set display/display_international
attributes."""
phone = super(cls, cls).from_dict(d)
phone.display = d.get('display', u'')
phone.display_international = d.get('display_international', u'')
return phone |
def to_dict(self):
"""Extend Field.to_dict, take the display_international attribute."""
d = Field.to_dict(self)
if self.display_international:
d['display_international'] = self.display_international
return d |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.