text_prompt stringlengths 100 17.7k ⌀ | code_prompt stringlengths 7 9.86k ⌀ |
|---|---|
<SYSTEM_TASK:>
Remove accents from characters in the given string.
<END_TASK>
<USER_TASK:>
Description:
def remove_accents(value):
"""
Remove accents from characters in the given string.
""" |
search = 'ΆΈΉΊΌΎΏάέήίόύώΪϊΐϋΰ'
replace = 'ΑΕΗΙΟΥΩαεηιουωΙιιυυ'
def replace_accented_character(match):
matched = match.group(0)
if matched in search:
return replace[search.find(matched)]
return matched
return re.sub(r'[{0}]+'.format(search), replace_accented_charact... |
<SYSTEM_TASK:>
Calculates and returns a control digit for given list of digits basing on REGON standard.
<END_TASK>
<USER_TASK:>
Description:
def regon_checksum(digits):
"""
Calculates and returns a control digit for given list of digits basing on REGON standard.
""" |
weights_for_check_digit = [8, 9, 2, 3, 4, 5, 6, 7]
check_digit = 0
for i in range(0, 8):
check_digit += weights_for_check_digit[i] * digits[i]
check_digit %= 11
if check_digit == 10:
check_digit = 0
return check_digit |
<SYSTEM_TASK:>
Calculates and returns a control digit for given list of digits basing on local REGON standard.
<END_TASK>
<USER_TASK:>
Description:
def local_regon_checksum(digits):
"""
Calculates and returns a control digit for given list of digits basing on local REGON standard.
""" |
weights_for_check_digit = [2, 4, 8, 5, 0, 9, 7, 3, 6, 1, 2, 4, 8]
check_digit = 0
for i in range(0, 13):
check_digit += weights_for_check_digit[i] * digits[i]
check_digit %= 11
if check_digit == 10:
check_digit = 0
return check_digit |
<SYSTEM_TASK:>
Calculates and returns a control digit for given list of digits basing on NIP standard.
<END_TASK>
<USER_TASK:>
Description:
def company_vat_checksum(digits):
"""
Calculates and returns a control digit for given list of digits basing on NIP standard.
""" |
weights_for_check_digit = [6, 5, 7, 2, 3, 4, 5, 6, 7]
check_digit = 0
for i in range(0, 9):
check_digit += weights_for_check_digit[i] * digits[i]
check_digit %= 11
return check_digit |
<SYSTEM_TASK:>
Returns a dictionary.
<END_TASK>
<USER_TASK:>
Description:
def pydict(self, nb_elements=10, variable_nb_elements=True, *value_types):
"""
Returns a dictionary.
:nb_elements: number of elements for dictionary
:variable_nb_elements: is use variable number of elements for di... |
if variable_nb_elements:
nb_elements = self.randomize_nb_elements(nb_elements, min=1)
return dict(zip(
self.generator.words(nb_elements),
self._pyiterable(nb_elements, False, *value_types),
)) |
<SYSTEM_TASK:>
Calculate and return control digit for given list of digits based on
<END_TASK>
<USER_TASK:>
Description:
def checksum(digits):
"""
Calculate and return control digit for given list of digits based on
ISO7064, MOD 11,10 standard.
""" |
remainder = 10
for digit in digits:
remainder = (remainder + digit) % 10
if remainder == 0:
remainder = 10
remainder = (remainder * 2) % 11
control_digit = 11 - remainder
if control_digit == 10:
control_digit = 0
return control_digit |
<SYSTEM_TASK:>
Calculate checksum of Estonian personal identity code.
<END_TASK>
<USER_TASK:>
Description:
def checksum(digits):
"""Calculate checksum of Estonian personal identity code.
Checksum is calculated with "Modulo 11" method using level I or II scale:
Level I scale: 1 2 3 4 5 6 7 8 9 1
Level I... |
sum_mod11 = sum(map(operator.mul, digits, Provider.scale1)) % 11
if sum_mod11 < 10:
return sum_mod11
sum_mod11 = sum(map(operator.mul, digits, Provider.scale2)) % 11
return 0 if sum_mod11 == 10 else sum_mod11 |
<SYSTEM_TASK:>
Optionally center the coord and pick a point within radius.
<END_TASK>
<USER_TASK:>
Description:
def coordinate(self, center=None, radius=0.001):
"""
Optionally center the coord and pick a point within radius.
""" |
if center is None:
return Decimal(str(self.generator.random.randint(-180000000, 180000000) / 1000000.0)).quantize(
Decimal(".000001"),
)
else:
center = float(center)
radius = float(radius)
geo = self.generator.random.uniform(ce... |
<SYSTEM_TASK:>
Calculates and returns a control digit for given list of digits basing on PESEL standard.
<END_TASK>
<USER_TASK:>
Description:
def checksum(digits):
"""
Calculates and returns a control digit for given list of digits basing on PESEL standard.
""" |
weights_for_check_digit = [9, 7, 3, 1, 9, 7, 3, 1, 9, 7]
check_digit = 0
for i in range(0, 10):
check_digit += weights_for_check_digit[i] * digits[i]
check_digit %= 10
return check_digit |
<SYSTEM_TASK:>
Calculates and returns a month number basing on PESEL standard.
<END_TASK>
<USER_TASK:>
Description:
def calculate_month(birth_date):
"""
Calculates and returns a month number basing on PESEL standard.
""" |
year = int(birth_date.strftime('%Y'))
month = int(birth_date.strftime('%m')) + ((int(year / 100) - 14) % 5) * 20
return month |
<SYSTEM_TASK:>
Returns a random integer between two values.
<END_TASK>
<USER_TASK:>
Description:
def random_int(self, min=0, max=9999, step=1):
"""
Returns a random integer between two values.
:param min: lower bound value (inclusive; default=0)
:param max: upper bound value (inclusive;... |
return self.generator.random.randrange(min, max + 1, step) |
<SYSTEM_TASK:>
Returns a list of random, non-unique elements from a passed object.
<END_TASK>
<USER_TASK:>
Description:
def random_choices(self, elements=('a', 'b', 'c'), length=None):
"""
Returns a list of random, non-unique elements from a passed object.
If `elements` is a dictionary, the val... |
return self.random_elements(elements, length, unique=False) |
<SYSTEM_TASK:>
Returns a list of random unique elements for the specified length.
<END_TASK>
<USER_TASK:>
Description:
def random_sample(self, elements=('a', 'b', 'c'), length=None):
"""
Returns a list of random unique elements for the specified length.
Multiple occurrences of the same value inc... |
return self.random_elements(elements, length, unique=True) |
<SYSTEM_TASK:>
Returns a random value near number.
<END_TASK>
<USER_TASK:>
Description:
def randomize_nb_elements(
self,
number=10,
le=False,
ge=False,
min=None,
max=None):
"""
Returns a random value near number.
:param num... |
if le and ge:
return number
_min = 100 if ge else 60
_max = 100 if le else 140
nb = int(number * self.generator.random.randint(_min, _max) / 100)
if min is not None and nb < min:
nb = min
if max is not None and nb > min:
nb = max
... |
<SYSTEM_TASK:>
Replaces all placeholders with random numbers and letters.
<END_TASK>
<USER_TASK:>
Description:
def bothify(self, text='## ??', letters=string.ascii_letters):
"""
Replaces all placeholders with random numbers and letters.
:param text: string to be parsed
:returns: string ... |
return self.lexify(self.numerify(text), letters=letters) |
<SYSTEM_TASK:>
Calculate checksum of Norwegian personal identity code.
<END_TASK>
<USER_TASK:>
Description:
def checksum(digits, scale):
"""
Calculate checksum of Norwegian personal identity code.
Checksum is calculated with "Module 11" method using a scale.
The digits of the personal code are multipli... |
chk_nbr = 11 - (sum(map(operator.mul, digits, scale)) % 11)
if chk_nbr == 11:
return 0
return chk_nbr |
<SYSTEM_TASK:>
Returns the century code for a given year
<END_TASK>
<USER_TASK:>
Description:
def _get_century_code(year):
"""Returns the century code for a given year""" |
if 2000 <= year < 3000:
separator = 'A'
elif 1900 <= year < 2000:
separator = '-'
elif 1800 <= year < 1900:
separator = '+'
else:
raise ValueError('Finnish SSN do not support people born before the year 1800 or after the year 2999')
... |
<SYSTEM_TASK:>
Returns a 10 digit Swedish SSN, "Personnummer".
<END_TASK>
<USER_TASK:>
Description:
def ssn(self, min_age=18, max_age=90):
"""
Returns a 10 digit Swedish SSN, "Personnummer".
It consists of 10 digits in the form YYMMDD-SSGQ, where
YYMMDD is the date of birth, SSS is a se... |
def _luhn_checksum(number):
def digits_of(n):
return [int(d) for d in str(n)]
digits = digits_of(number)
odd_digits = digits[-1::-2]
even_digits = digits[-2::-2]
checksum = 0
checksum += sum(odd_digits)
for d in... |
<SYSTEM_TASK:>
Generates a basic profile with personal informations
<END_TASK>
<USER_TASK:>
Description:
def simple_profile(self, sex=None):
"""
Generates a basic profile with personal informations
""" |
SEX = ["F", "M"]
if sex not in SEX:
sex = self.random_element(SEX)
if sex == 'F':
name = self.generator.name_female()
elif sex == 'M':
name = self.generator.name_male()
return {
"username": self.generator.user_name(),
"... |
<SYSTEM_TASK:>
Generates a complete profile.
<END_TASK>
<USER_TASK:>
Description:
def profile(self, fields=None, sex=None):
"""
Generates a complete profile.
If "fields" is not empty, only the fields in the list will be returned
""" |
if fields is None:
fields = []
d = {
"job": self.generator.job(),
"company": self.generator.company(),
"ssn": self.generator.ssn(),
"residence": self.generator.address(),
"current_location": (self.generator.latitude(), self.genera... |
<SYSTEM_TASK:>
Generate a safe datetime from a datetime.date or datetime.datetime object.
<END_TASK>
<USER_TASK:>
Description:
def new_datetime(d):
"""
Generate a safe datetime from a datetime.date or datetime.datetime object.
""" |
kw = [d.year, d.month, d.day]
if isinstance(d, real_datetime):
kw.extend([d.hour, d.minute, d.second, d.microsecond, d.tzinfo])
return datetime(*kw) |
<SYSTEM_TASK:>
Generate a random United States Taxpayer Identification Number of the specified type.
<END_TASK>
<USER_TASK:>
Description:
def ssn(self, taxpayer_identification_number_type=SSN_TYPE):
""" Generate a random United States Taxpayer Identification Number of the specified type.
If no type is ... |
if taxpayer_identification_number_type == self.ITIN_TYPE:
return self.itin()
elif taxpayer_identification_number_type == self.EIN_TYPE:
return self.ein()
elif taxpayer_identification_number_type == self.SSN_TYPE:
# Certain numbers are invalid for United Sta... |
<SYSTEM_TASK:>
Takes two DateTime objects and returns a random datetime between the two
<END_TASK>
<USER_TASK:>
Description:
def date_time_between_dates(
self,
datetime_start=None,
datetime_end=None,
tzinfo=None):
"""
Takes two DateTime objects and returns... |
if datetime_start is None:
datetime_start = datetime.now(tzinfo)
if datetime_end is None:
datetime_end = datetime.now(tzinfo)
timestamp = self.generator.random.randint(
datetime_to_timestamp(datetime_start),
datetime_to_timestamp(datetime_end),
... |
<SYSTEM_TASK:>
Gets a DateTime object for the current century.
<END_TASK>
<USER_TASK:>
Description:
def date_time_this_century(
self,
before_now=True,
after_now=False,
tzinfo=None):
"""
Gets a DateTime object for the current century.
:param before... |
now = datetime.now(tzinfo)
this_century_start = datetime(
now.year - (now.year % 100), 1, 1, tzinfo=tzinfo)
next_century_start = datetime(
min(this_century_start.year + 100, MAXYEAR), 1, 1, tzinfo=tzinfo)
if before_now and after_now:
return self.date... |
<SYSTEM_TASK:>
Gets a DateTime object for the decade year.
<END_TASK>
<USER_TASK:>
Description:
def date_time_this_decade(
self,
before_now=True,
after_now=False,
tzinfo=None):
"""
Gets a DateTime object for the decade year.
:param before_now: inc... |
now = datetime.now(tzinfo)
this_decade_start = datetime(
now.year - (now.year % 10), 1, 1, tzinfo=tzinfo)
next_decade_start = datetime(
min(this_decade_start.year + 10, MAXYEAR), 1, 1, tzinfo=tzinfo)
if before_now and after_now:
return self.date_time... |
<SYSTEM_TASK:>
Gets a DateTime object for the current year.
<END_TASK>
<USER_TASK:>
Description:
def date_time_this_year(
self,
before_now=True,
after_now=False,
tzinfo=None):
"""
Gets a DateTime object for the current year.
:param before_now: inc... |
now = datetime.now(tzinfo)
this_year_start = now.replace(
month=1, day=1, hour=0, minute=0, second=0, microsecond=0)
next_year_start = datetime(now.year + 1, 1, 1, tzinfo=tzinfo)
if before_now and after_now:
return self.date_time_between_dates(
t... |
<SYSTEM_TASK:>
Gets a DateTime object for the current month.
<END_TASK>
<USER_TASK:>
Description:
def date_time_this_month(
self,
before_now=True,
after_now=False,
tzinfo=None):
"""
Gets a DateTime object for the current month.
:param before_now: ... |
now = datetime.now(tzinfo)
this_month_start = now.replace(
day=1, hour=0, minute=0, second=0, microsecond=0)
next_month_start = this_month_start + \
relativedelta.relativedelta(months=1)
if before_now and after_now:
return self.date_time_between_date... |
<SYSTEM_TASK:>
Gets a Date object for the current century.
<END_TASK>
<USER_TASK:>
Description:
def date_this_century(self, before_today=True, after_today=False):
"""
Gets a Date object for the current century.
:param before_today: include days in current century before today
:param aft... |
today = date.today()
this_century_start = date(today.year - (today.year % 100), 1, 1)
next_century_start = date(this_century_start.year + 100, 1, 1)
if before_today and after_today:
return self.date_between_dates(
this_century_start, next_century_start)
... |
<SYSTEM_TASK:>
Gets a Date object for the decade year.
<END_TASK>
<USER_TASK:>
Description:
def date_this_decade(self, before_today=True, after_today=False):
"""
Gets a Date object for the decade year.
:param before_today: include days in current decade before today
:param after_today: ... |
today = date.today()
this_decade_start = date(today.year - (today.year % 10), 1, 1)
next_decade_start = date(this_decade_start.year + 10, 1, 1)
if before_today and after_today:
return self.date_between_dates(this_decade_start, next_decade_start)
elif not before_toda... |
<SYSTEM_TASK:>
Gets a Date object for the current year.
<END_TASK>
<USER_TASK:>
Description:
def date_this_year(self, before_today=True, after_today=False):
"""
Gets a Date object for the current year.
:param before_today: include days in current year before today
:param after_today: in... |
today = date.today()
this_year_start = today.replace(month=1, day=1)
next_year_start = date(today.year + 1, 1, 1)
if before_today and after_today:
return self.date_between_dates(this_year_start, next_year_start)
elif not before_today and after_today:
ret... |
<SYSTEM_TASK:>
Gets a Date object for the current month.
<END_TASK>
<USER_TASK:>
Description:
def date_this_month(self, before_today=True, after_today=False):
"""
Gets a Date object for the current month.
:param before_today: include days in current month before today
:param after_today... |
today = date.today()
this_month_start = today.replace(day=1)
next_month_start = this_month_start + \
relativedelta.relativedelta(months=1)
if before_today and after_today:
return self.date_between_dates(this_month_start, next_month_start)
elif not before... |
<SYSTEM_TASK:>
Generate a random date of birth represented as a Date object,
<END_TASK>
<USER_TASK:>
Description:
def date_of_birth(self, tzinfo=None, minimum_age=0, maximum_age=115):
"""
Generate a random date of birth represented as a Date object,
constrained by optional miminimum_age and maxi... |
if not isinstance(minimum_age, int):
raise TypeError("minimum_age must be an integer.")
if not isinstance(maximum_age, int):
raise TypeError("maximum_age must be an integer.")
if (maximum_age < 0):
raise ValueError("maximum_age must be greater than or equa... |
<SYSTEM_TASK:>
Adds two or more dicts together. Common keys will have their values added.
<END_TASK>
<USER_TASK:>
Description:
def add_dicts(*args):
"""
Adds two or more dicts together. Common keys will have their values added.
For example::
>>> t1 = {'a':1, 'b':2}
>>> t2 = {'b':1, 'c':3}
... |
counters = [Counter(arg) for arg in args]
return dict(reduce(operator.add, counters)) |
<SYSTEM_TASK:>
Returns the provider's name of the credit card.
<END_TASK>
<USER_TASK:>
Description:
def credit_card_provider(self, card_type=None):
""" Returns the provider's name of the credit card. """ |
if card_type is None:
card_type = self.random_element(self.credit_card_types.keys())
return self._credit_card_type(card_type).name |
<SYSTEM_TASK:>
Returns a valid credit card number.
<END_TASK>
<USER_TASK:>
Description:
def credit_card_number(self, card_type=None):
""" Returns a valid credit card number. """ |
card = self._credit_card_type(card_type)
prefix = self.random_element(card.prefixes)
number = self._generate_number(self.numerify(prefix), card.length)
return number |
<SYSTEM_TASK:>
Returns a random credit card type instance.
<END_TASK>
<USER_TASK:>
Description:
def _credit_card_type(self, card_type=None):
""" Returns a random credit card type instance. """ |
if card_type is None:
card_type = self.random_element(self.credit_card_types.keys())
elif isinstance(card_type, CreditCard):
return card_type
return self.credit_card_types[card_type] |
<SYSTEM_TASK:>
Returns a 11 digits Belgian SSN called "rijksregisternummer" as a string
<END_TASK>
<USER_TASK:>
Description:
def ssn(self):
"""
Returns a 11 digits Belgian SSN called "rijksregisternummer" as a string
The first 6 digits represent the birthdate with (in order) year, month and day... |
# see http://nl.wikipedia.org/wiki/Burgerservicenummer (in Dutch)
def _checksum(digits):
res = 97 - (digits % 97)
return res
# Generate a date (random)
mydate = self.generator.date()
# Convert it to an int
elms = mydate.split("-")
# Adjus... |
<SYSTEM_TASK:>
Determine validity of a Canadian Social Insurance Number.
<END_TASK>
<USER_TASK:>
Description:
def checksum(sin):
"""
Determine validity of a Canadian Social Insurance Number.
Validation is performed using a modified Luhn Algorithm. To check
the Every second digit of the SIN is doubled a... |
# Remove spaces and create a list of digits.
checksumCollection = list(sin.replace(' ', ''))
checksumCollection = [int(i) for i in checksumCollection]
# Discard the last digit, we will be calculating it later.
checksumCollection[-1] = 0
# Iterate over the provided SIN and double every second... |
<SYSTEM_TASK:>
Produce a hostname with specified number of subdomain levels.
<END_TASK>
<USER_TASK:>
Description:
def hostname(self, levels=1):
"""
Produce a hostname with specified number of subdomain levels.
>>> hostname()
db-01.nichols-phillips.com
>>> hostname(0)
lap... |
if levels < 1:
return self.random_element(self.hostname_prefixes) + '-' + self.numerify('##')
return self.random_element(self.hostname_prefixes) + '-' + self.numerify('##') + '.' + self.domain_name(levels) |
<SYSTEM_TASK:>
Produce an Internet domain name with the specified number of
<END_TASK>
<USER_TASK:>
Description:
def domain_name(self, levels=1):
"""
Produce an Internet domain name with the specified number of
subdomain levels.
>>> domain_name()
nichols-phillips.com
>>>... |
if levels < 1:
raise ValueError("levels must be greater than or equal to 1")
if levels == 1:
return self.domain_word() + '.' + self.tld()
else:
return self.domain_word() + '.' + self.domain_name(levels - 1) |
<SYSTEM_TASK:>
Produces a random IPv4 address or network with a valid CIDR
<END_TASK>
<USER_TASK:>
Description:
def _random_ipv4_address_from_subnet(self, subnet, network=False):
"""
Produces a random IPv4 address or network with a valid CIDR
from within a given subnet.
:param subnet: I... |
address = str(
subnet[self.generator.random.randint(
0, subnet.num_addresses - 1,
)],
)
if network:
address += '/' + str(self.generator.random.randint(
subnet.prefixlen,
subnet.max_prefixlen,
))
... |
<SYSTEM_TASK:>
Exclude the list of networks from another list of networks
<END_TASK>
<USER_TASK:>
Description:
def _exclude_ipv4_networks(self, networks, networks_to_exclude):
"""
Exclude the list of networks from another list of networks
and return a flat list of new networks.
:param n... |
for network_to_exclude in networks_to_exclude:
def _exclude_ipv4_network(network):
"""
Exclude a single network from another single network
and return a list of networks. Network to exclude
comes from the outer scope.
... |
<SYSTEM_TASK:>
Produce a random IPv4 address or network with a valid CIDR.
<END_TASK>
<USER_TASK:>
Description:
def ipv4(self, network=False, address_class=None, private=None):
"""
Produce a random IPv4 address or network with a valid CIDR.
:param network: Network address
:param address... |
if private is True:
return self.ipv4_private(address_class=address_class,
network=network)
elif private is False:
return self.ipv4_public(address_class=address_class,
network=network)
# if neither ... |
<SYSTEM_TASK:>
Returns a private IPv4.
<END_TASK>
<USER_TASK:>
Description:
def ipv4_private(self, network=False, address_class=None):
"""
Returns a private IPv4.
:param network: Network address
:param address_class: IPv4 address class (a, b, or c)
:returns: Private IPv4
... |
# compute private networks from given class
supernet = _IPv4Constants._network_classes[
address_class or self.ipv4_network_class()
]
private_networks = [
subnet for subnet in _IPv4Constants._private_networks
if subnet.overlaps(supernet)
]
... |
<SYSTEM_TASK:>
Returns a public IPv4 excluding private blocks.
<END_TASK>
<USER_TASK:>
Description:
def ipv4_public(self, network=False, address_class=None):
"""
Returns a public IPv4 excluding private blocks.
:param network: Network address
:param address_class: IPv4 address class (a, ... |
# compute public networks
public_networks = [_IPv4Constants._network_classes[
address_class or self.ipv4_network_class()
]]
# exclude private and excluded special networks
public_networks = self._exclude_ipv4_networks(
public_networks,
_IPv4C... |
<SYSTEM_TASK:>
Produce a random IPv6 address or network with a valid CIDR
<END_TASK>
<USER_TASK:>
Description:
def ipv6(self, network=False):
"""Produce a random IPv6 address or network with a valid CIDR""" |
address = str(ip_address(self.generator.random.randint(
2 ** IPV4LENGTH, (2 ** IPV6LENGTH) - 1)))
if network:
address += '/' + str(self.generator.random.randint(0, IPV6LENGTH))
address = str(ip_network(address, strict=False))
return address |
<SYSTEM_TASK:>
This is a secure way to make a fake from another Provider.
<END_TASK>
<USER_TASK:>
Description:
def format(self, formatter, *args, **kwargs):
"""
This is a secure way to make a fake from another Provider.
""" |
# TODO: data export?
return self.get_formatter(formatter)(*args, **kwargs) |
<SYSTEM_TASK:>
Perform a forward execution and perform alias analysis. Note that this analysis is fast, light-weight, and by no
<END_TASK>
<USER_TASK:>
Description:
def _alias_analysis(self, mock_sp=True, mock_bp=True):
"""
Perform a forward execution and perform alias analysis. Note that this analysis ... |
state = SimLightState(
regs={
self._arch.sp_offset: self._arch.initial_sp,
self._arch.bp_offset: self._arch.initial_sp + 0x2000, # TODO: take care of the relation between sp and bp
},
temps={},
options={
'mock_sp': moc... |
<SYSTEM_TASK:>
Prepare the address space with the data necessary to perform relocations pointing to the given symbol.
<END_TASK>
<USER_TASK:>
Description:
def prepare_function_symbol(self, symbol_name, basic_addr=None):
"""
Prepare the address space with the data necessary to perform relocations pointin... |
if self.project.loader.main_object.is_ppc64_abiv1:
if basic_addr is not None:
pointer = self.project.loader.memory.unpack_word(basic_addr)
return pointer, basic_addr
pseudo_hookaddr = self.project.loader.extern_object.get_pseudo_addr(symbol_name)
... |
<SYSTEM_TASK:>
Set the fs register in the angr to the value of the fs register in the concrete process
<END_TASK>
<USER_TASK:>
Description:
def initialize_segment_register_x64(self, state, concrete_target):
"""
Set the fs register in the angr to the value of the fs register in the concrete process
... |
_l.debug("Synchronizing fs segment register")
state.regs.fs = self._read_fs_register_x64(concrete_target) |
<SYSTEM_TASK:>
Create a GDT in the state memory and populate the segment registers.
<END_TASK>
<USER_TASK:>
Description:
def initialize_gdt_x86(self,state,concrete_target):
"""
Create a GDT in the state memory and populate the segment registers.
Rehook the vsyscall address using the real value i... |
_l.debug("Creating fake Global Descriptor Table and synchronizing gs segment register")
gs = self._read_gs_register_x86(concrete_target)
gdt = self.generate_gdt(0x0, gs)
self.setup_gdt(state, gdt)
# Synchronize the address of vsyscall in simprocedures dictionary with the concre... |
<SYSTEM_TASK:>
Merges this node with the other, returning a new node that spans the both.
<END_TASK>
<USER_TASK:>
Description:
def merge(self, other):
"""
Merges this node with the other, returning a new node that spans the both.
""" |
new_node = self.copy()
new_node.size += other.size
new_node.instruction_addrs += other.instruction_addrs
# FIXME: byte_string should never be none, but it is sometimes
# like, for example, patcherex test_cfg.py:test_fullcfg_properties
if new_node.byte_string is None or o... |
<SYSTEM_TASK:>
Allocates a new array in memory and returns the reference to the base.
<END_TASK>
<USER_TASK:>
Description:
def new_array(state, element_type, size):
"""
Allocates a new array in memory and returns the reference to the base.
""" |
size_bounded = SimSootExpr_NewArray._bound_array_size(state, size)
# return the reference of the array base
# => elements getting lazy initialized in the javavm memory
return SimSootValue_ArrayBaseRef(heap_alloc_id=state.javavm_memory.get_new_uuid(),
... |
<SYSTEM_TASK:>
Convert recovered reaching conditions from claripy ASTs to ailment Expressions
<END_TASK>
<USER_TASK:>
Description:
def _convert_claripy_bool_ast(self, cond):
"""
Convert recovered reaching conditions from claripy ASTs to ailment Expressions
:return: None
""" |
if isinstance(cond, ailment.Expr.Expression):
return cond
if cond.op == "BoolS" and claripy.is_true(cond):
return cond
if cond in self._condition_mapping:
return self._condition_mapping[cond]
_mapping = {
'Not': lambda cond_: ailment.Ex... |
<SYSTEM_TASK:>
Extract goto targets from a Jump or a ConditionalJump statement.
<END_TASK>
<USER_TASK:>
Description:
def _extract_jump_targets(stmt):
"""
Extract goto targets from a Jump or a ConditionalJump statement.
:param stmt: The statement to analyze.
:return: A list of ... |
targets = [ ]
# FIXME: We are assuming all jump targets are concrete targets. They may not be.
if isinstance(stmt, ailment.Stmt.Jump):
targets.append(stmt.target.value)
elif isinstance(stmt, ailment.Stmt.ConditionalJump):
targets.append(stmt.true_target.value)... |
<SYSTEM_TASK:>
A somewhat faithful implementation of libc `malloc`.
<END_TASK>
<USER_TASK:>
Description:
def malloc(self, sim_size):
"""
A somewhat faithful implementation of libc `malloc`.
:param sim_size: the amount of memory (in bytes) to be allocated
:returns: the address of ... |
raise NotImplementedError("%s not implemented for %s" % (self.malloc.__func__.__name__,
self.__class__.__name__)) |
<SYSTEM_TASK:>
A somewhat faithful implementation of libc `free`.
<END_TASK>
<USER_TASK:>
Description:
def free(self, ptr): #pylint:disable=unused-argument
"""
A somewhat faithful implementation of libc `free`.
:param ptr: the location in memory to be freed
""" |
raise NotImplementedError("%s not implemented for %s" % (self.free.__func__.__name__,
self.__class__.__name__)) |
<SYSTEM_TASK:>
A somewhat faithful implementation of libc `calloc`.
<END_TASK>
<USER_TASK:>
Description:
def calloc(self, sim_nmemb, sim_size):
"""
A somewhat faithful implementation of libc `calloc`.
:param sim_nmemb: the number of elements to allocated
:param sim_size: the siz... |
raise NotImplementedError("%s not implemented for %s" % (self.calloc.__func__.__name__,
self.__class__.__name__)) |
<SYSTEM_TASK:>
A somewhat faithful implementation of libc `realloc`.
<END_TASK>
<USER_TASK:>
Description:
def realloc(self, ptr, size):
"""
A somewhat faithful implementation of libc `realloc`.
:param ptr: the location in memory to be reallocated
:param size: the new size desired for t... |
raise NotImplementedError("%s not implemented for %s" % (self.realloc.__func__.__name__,
self.__class__.__name__)) |
<SYSTEM_TASK:>
Initialize register values within the state
<END_TASK>
<USER_TASK:>
Description:
def set_regs(self, regs_dump):
"""
Initialize register values within the state
:param regs_dump: The output of ``info registers`` in gdb.
""" |
if self.real_stack_top == 0 and self.adjust_stack is True:
raise SimStateError("You need to set the stack first, or set"
"adjust_stack to False. Beware that in this case, sp and bp won't be updated")
data = self._read_data(regs_dump)
rdata = re.split(b"\n", dat... |
<SYSTEM_TASK:>
Adjust bp and sp w.r.t. stack difference between GDB session and angr.
<END_TASK>
<USER_TASK:>
Description:
def _adjust_regs(self):
"""
Adjust bp and sp w.r.t. stack difference between GDB session and angr.
This matches sp and bp registers, but there is a high risk of pointers inc... |
if not self.adjust_stack:
return
bp = self.state.arch.register_names[self.state.arch.bp_offset]
sp = self.state.arch.register_names[self.state.arch.sp_offset]
stack_shift = self.state.arch.initial_sp - self.real_stack_top
self.state.registers.store(sp, self.state.r... |
<SYSTEM_TASK:>
Create a Loop object for a strongly connected graph, and any strongly
<END_TASK>
<USER_TASK:>
Description:
def _parse_loop_graph(self, subg, bigg):
"""
Create a Loop object for a strongly connected graph, and any strongly
connected subgraphs, if possible.
:param subg: ... |
loop_body_nodes = list(subg.nodes())[:]
entry_edges = []
break_edges = []
continue_edges = []
entry_node = None
for node in loop_body_nodes:
for pred_node in bigg.predecessors(node):
if pred_node not in loop_body_nodes:
if ... |
<SYSTEM_TASK:>
Return all Loop instances that can be extracted from a graph.
<END_TASK>
<USER_TASK:>
Description:
def _parse_loops_from_graph(self, graph):
"""
Return all Loop instances that can be extracted from a graph.
:param graph: The graph to analyze.
:return: A list of ... |
outtop = []
outall = []
for subg in networkx.strongly_connected_component_subgraphs(graph):
if len(subg.nodes()) == 1:
if len(list(subg.successors(list(subg.nodes())[0]))) == 0:
continue
thisloop, allloops = self._parse_loop_graph(subg... |
<SYSTEM_TASK:>
Resolve the field within the given state.
<END_TASK>
<USER_TASK:>
Description:
def get_ref(cls, state, obj_alloc_id, field_class_name, field_name, field_type):
"""
Resolve the field within the given state.
""" |
# resolve field
field_class = state.javavm_classloader.get_class(field_class_name)
field_id = resolve_field(state, field_class, field_name, field_type)
# return field ref
return cls.from_field_id(obj_alloc_id, field_id) |
<SYSTEM_TASK:>
This function calculates the levenshtein distance but allows for elements in the lists to be different by any number
<END_TASK>
<USER_TASK:>
Description:
def _normalized_levenshtein_distance(s1, s2, acceptable_differences):
"""
This function calculates the levenshtein distance but allows for elem... |
if len(s1) > len(s2):
s1, s2 = s2, s1
acceptable_differences = set(-i for i in acceptable_differences)
distances = range(len(s1) + 1)
for index2, num2 in enumerate(s2):
new_distances = [index2 + 1]
for index1, num1 in enumerate(s1):
if num2 - num1 in acceptable_d... |
<SYSTEM_TASK:>
Compares two basic blocks and finds all the constants that differ from the first block to the second.
<END_TASK>
<USER_TASK:>
Description:
def differing_constants(block_a, block_b):
"""
Compares two basic blocks and finds all the constants that differ from the first block to the second.
:par... |
statements_a = [s for s in block_a.vex.statements if s.tag != "Ist_IMark"] + [block_a.vex.next]
statements_b = [s for s in block_b.vex.statements if s.tag != "Ist_IMark"] + [block_b.vex.next]
if len(statements_a) != len(statements_b):
raise UnmatchedStatementsException("Blocks have different number... |
<SYSTEM_TASK:>
Compare two functions and return True if they appear identical.
<END_TASK>
<USER_TASK:>
Description:
def functions_probably_identical(self, func_a_addr, func_b_addr, check_consts=False):
"""
Compare two functions and return True if they appear identical.
:param func_a_addr: The a... |
if self.cfg_a.project.is_hooked(func_a_addr) and self.cfg_b.project.is_hooked(func_b_addr):
return self.cfg_a.project._sim_procedures[func_a_addr] == self.cfg_b.project._sim_procedures[func_b_addr]
func_diff = self.get_function_diff(func_a_addr, func_b_addr)
if check_consts:
... |
<SYSTEM_TASK:>
Load a new project based on a string of raw bytecode.
<END_TASK>
<USER_TASK:>
Description:
def load_shellcode(shellcode, arch, start_offset=0, load_address=0):
"""
Load a new project based on a string of raw bytecode.
:param shellcode: The data to load
:param arch: The n... |
return Project(
BytesIO(shellcode),
main_opts={
'backend': 'blob',
'arch': arch,
'entry_point': start_offset,
'base_addr': load_address,
}
) |
<SYSTEM_TASK:>
Has symbol name `f` been marked for exclusion by any of the user
<END_TASK>
<USER_TASK:>
Description:
def _check_user_blacklists(self, f):
"""
Has symbol name `f` been marked for exclusion by any of the user
parameters?
""" |
return not self._should_use_sim_procedures or \
f in self._exclude_sim_procedures_list or \
f in self._ignore_functions or \
(self._exclude_sim_procedures_func is not None and self._exclude_sim_procedures_func(f)) |
<SYSTEM_TASK:>
Hook a section of code with a custom function. This is used internally to provide symbolic
<END_TASK>
<USER_TASK:>
Description:
def hook(self, addr, hook=None, length=0, kwargs=None, replace=False):
"""
Hook a section of code with a custom function. This is used internally to provide symb... |
if hook is None:
# if we haven't been passed a thing to hook with, assume we're being used as a decorator
return self._hook_decorator(addr, length=length, kwargs=kwargs)
if kwargs is None: kwargs = {}
l.debug('hooking %s with %s', self._addr_to_str(addr), str(hook))
... |
<SYSTEM_TASK:>
Returns the current hook for `addr`.
<END_TASK>
<USER_TASK:>
Description:
def hooked_by(self, addr):
"""
Returns the current hook for `addr`.
:param addr: An address.
:returns: None if the address is not hooked.
""" |
if not self.is_hooked(addr):
l.warning("Address %s is not hooked", self._addr_to_str(addr))
return None
return self._sim_procedures[addr] |
<SYSTEM_TASK:>
Remove a hook.
<END_TASK>
<USER_TASK:>
Description:
def unhook(self, addr):
"""
Remove a hook.
:param addr: The address of the hook.
""" |
if not self.is_hooked(addr):
l.warning("Address %s not hooked", self._addr_to_str(addr))
return
del self._sim_procedures[addr] |
<SYSTEM_TASK:>
Resolve a dependency in a binary. Looks up the address of the given symbol, and then hooks that
<END_TASK>
<USER_TASK:>
Description:
def hook_symbol(self, symbol_name, simproc, kwargs=None, replace=None):
"""
Resolve a dependency in a binary. Looks up the address of the given symbol, and ... |
if type(symbol_name) is not int:
sym = self.loader.find_symbol(symbol_name)
if sym is None:
# it could be a previously unresolved weak symbol..?
new_sym = None
for reloc in self.loader.find_relevant_relocations(symbol_name):
... |
<SYSTEM_TASK:>
Check if a symbol is already hooked.
<END_TASK>
<USER_TASK:>
Description:
def is_symbol_hooked(self, symbol_name):
"""
Check if a symbol is already hooked.
:param str symbol_name: Name of the symbol.
:return: True if the symbol can be resolved and is hooked, False otherwi... |
sym = self.loader.find_symbol(symbol_name)
if sym is None:
l.warning("Could not find symbol %s", symbol_name)
return False
hook_addr, _ = self.simos.prepare_function_symbol(symbol_name, basic_addr=sym.rebased_addr)
return self.is_hooked(hook_addr) |
<SYSTEM_TASK:>
Remove the hook on a symbol.
<END_TASK>
<USER_TASK:>
Description:
def unhook_symbol(self, symbol_name):
"""
Remove the hook on a symbol.
This function will fail if the symbol is provided by the extern object, as that would result in a state where
analysis would be unable t... |
sym = self.loader.find_symbol(symbol_name)
if sym is None:
l.warning("Could not find symbol %s", symbol_name)
return False
if sym.owner is self.loader._extern_object:
l.warning("Refusing to unhook external symbol %s, replace it with another hook if you want t... |
<SYSTEM_TASK:>
Indicates if the project's main binary is a Java Archive.
<END_TASK>
<USER_TASK:>
Description:
def is_java_project(self):
"""
Indicates if the project's main binary is a Java Archive.
""" |
if self._is_java_project is None:
self._is_java_project = isinstance(self.arch, ArchSoot)
return self._is_java_project |
<SYSTEM_TASK:>
Register a preset instance with the class of the hub it corresponds to. This allows individual plugin objects to
<END_TASK>
<USER_TASK:>
Description:
def register_preset(cls, name, preset):
"""
Register a preset instance with the class of the hub it corresponds to. This allows individual ... |
if cls._presets is None:
cls._presets = {}
cls._presets[name] = preset |
<SYSTEM_TASK:>
Apply a preset to the hub. If there was a previously active preset, discard it.
<END_TASK>
<USER_TASK:>
Description:
def use_plugin_preset(self, preset):
"""
Apply a preset to the hub. If there was a previously active preset, discard it.
Preset can be either the string name of a ... |
if isinstance(preset, str):
try:
preset = self._presets[preset]
except (AttributeError, KeyError):
raise AngrNoPluginError("There is no preset named %s" % preset)
elif not isinstance(preset, PluginPreset):
raise ValueError("Argument m... |
<SYSTEM_TASK:>
Discard the current active preset. Will release any active plugins that could have come from the old preset.
<END_TASK>
<USER_TASK:>
Description:
def discard_plugin_preset(self):
"""
Discard the current active preset. Will release any active plugins that could have come from the old prese... |
if self.has_plugin_preset:
for name, plugin in list(self._active_plugins.items()):
if id(plugin) in self._provided_by_preset:
self.release_plugin(name)
self._active_preset.deactivate(self)
self._active_preset = None |
<SYSTEM_TASK:>
Get the plugin named ``name``. If no such plugin is currently active, try to activate a new
<END_TASK>
<USER_TASK:>
Description:
def get_plugin(self, name):
"""
Get the plugin named ``name``. If no such plugin is currently active, try to activate a new
one using the current preset... |
if name in self._active_plugins:
return self._active_plugins[name]
elif self.has_plugin_preset:
plugin_cls = self._active_preset.request_plugin(name)
plugin = self._init_plugin(plugin_cls)
# Remember that this plugin was provided by preset.
... |
<SYSTEM_TASK:>
Add a new plugin ``plugin`` with name ``name`` to the active plugins.
<END_TASK>
<USER_TASK:>
Description:
def register_plugin(self, name, plugin):
"""
Add a new plugin ``plugin`` with name ``name`` to the active plugins.
""" |
if self.has_plugin(name):
self.release_plugin(name)
self._active_plugins[name] = plugin
setattr(self, name, plugin)
return plugin |
<SYSTEM_TASK:>
Deactivate and remove the plugin with name ``name``.
<END_TASK>
<USER_TASK:>
Description:
def release_plugin(self, name):
"""
Deactivate and remove the plugin with name ``name``.
""" |
plugin = self._active_plugins[name]
if id(plugin) in self._provided_by_preset:
self._provided_by_preset.remove(id(plugin))
del self._active_plugins[name]
delattr(self, name) |
<SYSTEM_TASK:>
Grabs the concretized result so we can add the constraint ourselves.
<END_TASK>
<USER_TASK:>
Description:
def _grab_concretization_results(cls, state):
"""
Grabs the concretized result so we can add the constraint ourselves.
""" |
# only grab ones that match the constrained addrs
if cls._should_add_constraints(state):
addr = state.inspect.address_concretization_expr
result = state.inspect.address_concretization_result
if result is None:
l.warning("addr concretization result is ... |
<SYSTEM_TASK:>
Check to see if the current address concretization variable is any of the registered
<END_TASK>
<USER_TASK:>
Description:
def _should_add_constraints(cls, state):
"""
Check to see if the current address concretization variable is any of the registered
constrained_addrs we want to ... |
expr = state.inspect.address_concretization_expr
hit_indices = cls._to_indices(state, expr)
for action in state.preconstrainer._constrained_addrs:
var_indices = cls._to_indices(state, action.addr)
if var_indices == hit_indices:
return True
return... |
<SYSTEM_TASK:>
The actual allocation primitive for this heap implementation. Increases the position of the break to allocate
<END_TASK>
<USER_TASK:>
Description:
def allocate(self, sim_size):
"""
The actual allocation primitive for this heap implementation. Increases the position of the break to allocat... |
size = self._conc_alloc_size(sim_size)
addr = self.state.heap.heap_location
self.state.heap.heap_location += size
l.debug("Allocating %d bytes at address %#08x", size, addr)
return addr |
<SYSTEM_TASK:>
The memory release primitive for this heap implementation. Decreases the position of the break to deallocate
<END_TASK>
<USER_TASK:>
Description:
def release(self, sim_size):
"""
The memory release primitive for this heap implementation. Decreases the position of the break to deallocate
... |
requested = self._conc_alloc_size(sim_size)
used = self.heap_location - self.heap_base
released = requested if requested <= used else used
self.heap_location -= released
l.debug("Releasing %d bytes from the heap (%d bytes were requested to be released)", released, requested) |
<SYSTEM_TASK:>
Get the function name from a C-style function declaration string.
<END_TASK>
<USER_TASK:>
Description:
def get_function_name(s):
"""
Get the function name from a C-style function declaration string.
:param str s: A C-style function declaration string.
:return: The function name.
... |
s = s.strip()
if s.startswith("__attribute__"):
# Remove "__attribute__ ((foobar))"
if "))" not in s:
raise ValueError("__attribute__ is present, but I cannot find double-right parenthesis in the function "
"declaration string.")
s = s[s.index(... |
<SYSTEM_TASK:>
Convert a C-style function declaration string to its corresponding SimTypes-based Python representation.
<END_TASK>
<USER_TASK:>
Description:
def convert_cproto_to_py(c_decl):
"""
Convert a C-style function declaration string to its corresponding SimTypes-based Python representation.
:param ... |
s = [ ]
try:
s.append('# %s' % c_decl) # comment string
parsed = parse_file(c_decl)
parsed_decl = parsed[0]
if not parsed_decl:
raise ValueError('Cannot parse the function prototype.')
func_name, func_proto = next(iter(parsed_decl.items()))
s.ap... |
<SYSTEM_TASK:>
Returns a concrete state of the flag indicating whether the previous chunk is free or not. Issues a warning if
<END_TASK>
<USER_TASK:>
Description:
def is_prev_free(self):
"""
Returns a concrete state of the flag indicating whether the previous chunk is free or not. Issues a warning if
... |
flag = self.state.memory.load(self.base + self._chunk_size_t_size, self._chunk_size_t_size) & CHUNK_P_MASK
def sym_flag_handler(flag):
l.warning("A chunk's P flag is symbolic; assuming it is not set")
return self.state.solver.min_int(flag)
flag = concretize(flag, self.... |
<SYSTEM_TASK:>
Returns the chunk following this chunk in the list of free chunks. If this chunk is not free, then it resides in
<END_TASK>
<USER_TASK:>
Description:
def fwd_chunk(self):
"""
Returns the chunk following this chunk in the list of free chunks. If this chunk is not free, then it resides in
... |
if self.is_free():
base = self.state.memory.load(self.base + 2 * self._chunk_size_t_size, self._chunk_size_t_size)
return PTChunk(base, self.state)
else:
raise SimHeapError("Attempted to access the forward chunk of an allocated chunk") |
<SYSTEM_TASK:>
Simply finds the free chunk that would be the backwards chunk relative to the chunk at ptr. Hence, the free head
<END_TASK>
<USER_TASK:>
Description:
def _find_bck(self, chunk):
"""
Simply finds the free chunk that would be the backwards chunk relative to the chunk at ptr. Hence, the free... |
cur = self.free_head_chunk
if cur is None:
return None
fwd = cur.fwd_chunk()
if cur == fwd:
return cur
# At this point there should be at least two free chunks in the heap
if cur < chunk:
while cur < fwd < chunk:
cur = ... |
<SYSTEM_TASK:>
Sets the freedom of the final chunk. Since no proper chunk follows the final chunk, the heap itself manages
<END_TASK>
<USER_TASK:>
Description:
def _set_final_freeness(self, flag):
"""
Sets the freedom of the final chunk. Since no proper chunk follows the final chunk, the heap itself man... |
if flag:
self.state.memory.store(self.heap_base + self.heap_size - self._chunk_size_t_size, ~CHUNK_P_MASK)
else:
self.state.memory.store(self.heap_base + self.heap_size - self._chunk_size_t_size, CHUNK_P_MASK) |
<SYSTEM_TASK:>
Takes an allocation size as requested by the user and modifies it to be a suitable chunk size.
<END_TASK>
<USER_TASK:>
Description:
def _make_chunk_size(self, req_size):
"""
Takes an allocation size as requested by the user and modifies it to be a suitable chunk size.
""" |
size = req_size
size += 2 * self._chunk_size_t_size # Two size fields
size = self._chunk_min_size if size < self._chunk_min_size else size
if size & self._chunk_align_mask: # If the chunk would not be aligned
size = (size & ~self._chu... |
<SYSTEM_TASK:>
Allocate and initialize a new string in the context of the state passed.
<END_TASK>
<USER_TASK:>
Description:
def new_string(state, value):
"""
Allocate and initialize a new string in the context of the state passed.
The method returns the reference to the newly allocated string
... |
str_ref = SimSootValue_StringRef(state.memory.get_new_uuid())
state.memory.store(str_ref, value)
return str_ref |
<SYSTEM_TASK:>
loads a number from addr, and returns a condition that addr must start with the prefix
<END_TASK>
<USER_TASK:>
Description:
def _load_num_with_prefix(prefix, addr, region, state, base, signed, read_length=None):
"""
loads a number from addr, and returns a condition that addr must start wi... |
length = len(prefix)
read_length = (read_length-length) if read_length else None
condition, value, num_bytes = strtol._string_to_int(addr+length, state, region, base, signed, read_length)
# the prefix must match
if len(prefix) > 0:
loaded_prefix = region.load(addr, ... |
<SYSTEM_TASK:>
reads values from s and generates the symbolic number that it would equal
<END_TASK>
<USER_TASK:>
Description:
def _string_to_int(s, state, region, base, signed, read_length=None):
"""
reads values from s and generates the symbolic number that it would equal
the first char is eith... |
# if length wasn't provided, read the maximum bytes
length = state.libc.max_strtol_len if read_length is None else read_length
# expression whether or not it was valid at all
expression, _ = strtol._char_to_val(region.load(s, 1), base)
cases = []
# to detect overflow... |
<SYSTEM_TASK:>
converts a symbolic char to a number in the given base
<END_TASK>
<USER_TASK:>
Description:
def _char_to_val(char, base):
"""
converts a symbolic char to a number in the given base
returns expression, result
expression is a symbolic boolean indicating whether or not it was... |
cases = []
# 0-9
max_digit = claripy.BVV(b"9")
min_digit = claripy.BVV(b"0")
if base < 10:
max_digit = claripy.BVV(ord("0") + base, 8)
is_digit = claripy.And(char >= min_digit, char <= max_digit)
# return early here so we don't add unnecessary stateme... |
<SYSTEM_TASK:>
Implement printf - based on the stored format specifier information, format the values from the arg getter function `args` into a string.
<END_TASK>
<USER_TASK:>
Description:
def replace(self, startpos, args):
"""
Implement printf - based on the stored format specifier information, format... |
argpos = startpos
string = None
for component in self.components:
# if this is just concrete data
if isinstance(component, bytes):
string = self._add_to_string(string, self.parser.state.solver.BVV(component))
elif isinstance(component, str):... |
<SYSTEM_TASK:>
All specifiers and their lengths.
<END_TASK>
<USER_TASK:>
Description:
def _all_spec(self):
"""
All specifiers and their lengths.
""" |
base = self._mod_spec
for spec in self.basic_spec:
base[spec] = self.basic_spec[spec]
return base |
<SYSTEM_TASK:>
match the string `nugget` to a format specifier.
<END_TASK>
<USER_TASK:>
Description:
def _match_spec(self, nugget):
"""
match the string `nugget` to a format specifier.
""" |
# TODO: handle positional modifiers and other similar format string tricks.
all_spec = self._all_spec
# iterate through nugget throwing away anything which is an int
# TODO store this in a size variable
original_nugget = nugget
length_str = [ ]
length_spec = No... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.