id int64 0 190k | prompt stringlengths 21 13.4M | docstring stringlengths 1 12k ⌀ |
|---|---|---|
3,166 | import collections
from beancount.core import data
ConfigError = collections.namedtuple('ConfigError', 'source message entry')
CommodityError = collections.namedtuple('CommodityError', 'source message entry')
The provided code snippet includes necessary dependencies for implementing the `validate_commodity_attr` funct... | Check that all Commodity directives have a valid attribute. Args: entries: A list of directives. unused_options_map: An options map. config_str: A configuration string. Returns: A list of new errors, if any were found. |
3,167 | from beancount.core import data
from beancount.core import getters
The provided code snippet includes necessary dependencies for implementing the `auto_insert_open` function. Write a Python function `def auto_insert_open(entries, unused_options_map)` to solve the following problem:
Insert Open directives for accounts ... | Insert Open directives for accounts not opened. Open directives are inserted at the date of the first entry. Open directives for unused accounts are removed. Args: entries: A list of directives. unused_options_map: A parser options dict. Returns: A list of entries, possibly with more Open entries than before, and a lis... |
3,168 | import collections
from beancount.core.number import ZERO
from beancount.core import data
from beancount.core import amount
from beancount.core import convert
from beancount.core import inventory
from beancount.core import account_types
from beancount.core import interpolate
from beancount.parser import options
SellGai... | Check the sum of asset account totals for lots sold with a price on them. Args: entries: A list of directives. unused_options_map: An options map. Returns: A list of new errors, if any were found. |
3,169 | import collections
from beancount.core import data
UniquePricesError = collections.namedtuple('UniquePricesError', 'source message entry')
The provided code snippet includes necessary dependencies for implementing the `validate_unique_prices` function. Write a Python function `def validate_unique_prices(entries, unuse... | Check that there is only a single price per day for a particular base/quote. Args: entries: A list of directives. We're interested only in the Transaction instances. unused_options_map: A parser options dict. Returns: The list of input entries, and a list of new UniquePricesError instances generated. |
3,170 | import collections
from beancount.core import data
CoherentCostError = collections.namedtuple('CoherentCostError', 'source message entry')
The provided code snippet includes necessary dependencies for implementing the `validate_coherent_cost` function. Write a Python function `def validate_coherent_cost(entries, unuse... | Check that all currencies are either used at cost or not at all, but never both. Args: entries: A list of directives. unused_options_map: An options map. Returns: A list of new errors, if any were found. |
3,171 | import collections
from beancount.core import data
from beancount.core import getters
UnusedAccountError = collections.namedtuple('UnusedAccountError', 'source message entry')
The provided code snippet includes necessary dependencies for implementing the `validate_unused_accounts` function. Write a Python function `de... | Check that all accounts declared open are actually used. We check that all of the accounts that are open are at least referred to by another directive. These are probably unused, so issue a warning (we like to be pedantic). Note that an account that is open and then closed is considered used--this is a valid use case t... |
3,172 | import collections
from beancount.core.data import Transaction
from beancount.core import data
from beancount.core import amount
from beancount.core import inventory
METADATA_FIELD = "__implicit_prices__"
class Transaction(NamedTuple):
"""
A transaction! This is the main type of object that we manipulate, and ... | Insert implicitly defined prices from Transactions. Explicit price entries are simply maintained in the output list. Prices from postings with costs or with prices from Transaction entries are synthesized as new Price entries in the list of entries output. Args: entries: A list of directives. We're interested only in t... |
3,173 | from beancount.core import compare
The provided code snippet includes necessary dependencies for implementing the `validate_no_duplicates` function. Write a Python function `def validate_no_duplicates(entries, unused_options_map)` to solve the following problem:
Check that the entries are unique, by computing hashes. ... | Check that the entries are unique, by computing hashes. Args: entries: A list of directives. unused_options_map: An options map. Returns: A list of new errors, if any were found. |
3,174 | import collections
from beancount.core.number import ZERO
from beancount.core.number import D
from beancount.core.data import Transaction
from beancount.core.data import Booking
from beancount.core import getters
from beancount.core import inventory
MatchBasisError = collections.namedtuple('MatchBasisError', 'source me... | Check that reducing legs on unbooked postings are near the average cost basis. Args: entries: A list of directives. unused_options_map: An options map. config_str: The configuration as a string version of a float. Returns: A list of new errors, if any were found. |
3,175 | from beancount.core import data
from beancount.core.data import Open, Close
class Open(NamedTuple):
"""
An "open account" directive.
Attributes:
meta: See above.
date: See above.
account: A string, the name of the account that is being opened.
currencies: A list of strings, currenc... | Insert close entries for all subaccounts of a closed account. Args: entries: A list of directives. We're interested only in the Open/Close instances. unused_options_map: A parser options dict. Returns: A tuple of entries and errors. |
3,176 | import collections
from beancount.core.data import Posting
from beancount.core.data import Transaction
from beancount.core import account
from beancount.core import convert
from beancount.core import data
from beancount.core import inventory
META_PROCESSED = 'currency_accounts_processed'
DEFAULT_BASE_ACCOUNT = 'Equity:... | Insert currency trading postings. Args: entries: A list of directives. unused_options_map: An options map. config: The base account name for currency trading accounts. Returns: A list of new errors, if any were found. |
3,177 | import argparse
import collections
import re
import sys
The provided code snippet includes necessary dependencies for implementing the `dump_tree` function. Write a Python function `def dump_tree(node, file=sys.stdout, prefix='')` to solve the following problem:
Render a tree as a tree. Args: node: An instance of Node... | Render a tree as a tree. Args: node: An instance of Node. file: A file object to write to. prefix: A prefix string for each of the lines of the children. |
3,178 | import argparse
import collections
import re
import sys
DEFAULT_PATTERN = (r"(Assets|Liabilities|Equity|Income|Expenses)"
r"(:[A-Z][A-Za-z0-9-_']*)*")
DEFAULT_DELIMITER = "[ \t]+"
DEFAULT_SPLITTER = ":"
LOOSE_PATTERN = r"\b([A-Za-z0-9-_']+)(:[A-Za-z0-9-_']+)+\b"
LOOSE_SPLITTER = r":"
FILENAME_PATTERN... | null |
3,179 | from collections import defaultdict
from time import time
import collections
import contextlib
import functools
import io
import re
import sys
import warnings
The provided code snippet includes necessary dependencies for implementing the `deprecated` function. Write a Python function `def deprecated(message)` to solve... | A decorator generator to mark functions as deprecated and log a warning. |
3,180 | from collections import defaultdict
from time import time
import collections
import contextlib
import functools
import io
import re
import sys
import warnings
The provided code snippet includes necessary dependencies for implementing the `box` function. Write a Python function `def box(name=None, file=None)` to solve ... | A context manager that prints out a box around a block. This is useful for printing out stuff from tests in a way that is readable. Args: name: A string, the name of the box to use. file: The file object to print to. Yields: None. |
3,181 | from collections import defaultdict
from time import time
import collections
import contextlib
import functools
import io
import re
import sys
import warnings
The provided code snippet includes necessary dependencies for implementing the `longest` function. Write a Python function `def longest(seq)` to solve the follo... | Return the longest of the given subsequences. Args: seq: An iterable sequence of lists. Returns: The longest list from the sequence. |
3,182 | from collections import defaultdict
from time import time
import collections
import contextlib
import functools
import io
import re
import sys
import warnings
The provided code snippet includes necessary dependencies for implementing the `get_tuple_values` function. Write a Python function `def get_tuple_values(ntuple... | Return all members referred to by this namedtuple instance that satisfy the given predicate. This function also works recursively on its members which are lists or tuples, and so it can be used for Transaction instances. Args: ntuple: A tuple or namedtuple. predicate: A predicate function that returns true if an attrib... |
3,183 | from collections import defaultdict
from time import time
import collections
import contextlib
import functools
import io
import re
import sys
import warnings
The provided code snippet includes necessary dependencies for implementing the `replace_namedtuple_values` function. Write a Python function `def replace_namedt... | Recurse through all the members of namedtuples and lists, and for members that match the given predicate, run them through the given mapper. Args: ntuple: A namedtuple instance. predicate: A predicate function that returns true if an attribute is to be output. mapper: A callable, that will accept a single argument and ... |
3,184 | from collections import defaultdict
from time import time
import collections
import contextlib
import functools
import io
import re
import sys
import warnings
The provided code snippet includes necessary dependencies for implementing the `compute_unique_clean_ids` function. Write a Python function `def compute_unique_... | Given a sequence of strings, reduce them to corresponding ids without any funny characters and insure that the list of ids is unique. Yields pairs of (id, string) for the result. Args: strings: A list of strings. Returns: A list of (id, string) pairs. |
3,185 | from collections import defaultdict
from time import time
import collections
import contextlib
import functools
import io
import re
import sys
import warnings
The provided code snippet includes necessary dependencies for implementing the `escape_string` function. Write a Python function `def escape_string(string)` to ... | Escape quotes and backslashes in payee and narration. Args: string: Any string. Returns. The input string, with offending characters replaced. |
3,186 | from collections import defaultdict
from time import time
import collections
import contextlib
import functools
import io
import re
import sys
import warnings
The provided code snippet includes necessary dependencies for implementing the `idify` function. Write a Python function `def idify(string)` to solve the follow... | Replace characters objectionable for a filename with underscores. Args: string: Any string. Returns: The input string, with offending characters replaced. |
3,187 | from collections import defaultdict
from time import time
import collections
import contextlib
import functools
import io
import re
import sys
import warnings
The provided code snippet includes necessary dependencies for implementing the `dictmap` function. Write a Python function `def dictmap(mdict, keyfun=None, valf... | Map a dictionary's value. Args: mdict: A dict. key: A callable to apply to the keys. value: A callable to apply to the values. |
3,188 | from collections import defaultdict
from time import time
import collections
import contextlib
import functools
import io
import re
import sys
import warnings
The provided code snippet includes necessary dependencies for implementing the `map_namedtuple_attributes` function. Write a Python function `def map_namedtuple... | Map the value of the named attributes of object by mapper. Args: attributes: A sequence of string, the attribute names to map. mapper: A callable that accepts the value of a field and returns the new value. object_: Some namedtuple object with attributes on it. Returns: A new instance of the same namedtuple with the na... |
3,189 | from collections import defaultdict
from time import time
import collections
import contextlib
import functools
import io
import re
import sys
import warnings
The provided code snippet includes necessary dependencies for implementing the `staticvar` function. Write a Python function `def staticvar(varname, initial_val... | Returns a decorator that defines a Python function attribute. This is used to simulate a static function variable in Python. Args: varname: A string, the name of the variable to define. initial_value: The value to initialize the variable to. Returns: A function decorator. |
3,190 | from collections import defaultdict
from time import time
import collections
import contextlib
import functools
import io
import re
import sys
import warnings
The provided code snippet includes necessary dependencies for implementing the `first_paragraph` function. Write a Python function `def first_paragraph(docstrin... | Return the first sentence of a docstring. The sentence has to be delimited by an empty line. Args: docstring: A doc string. Returns: A string with just the first sentence on a single line. |
3,191 | from collections import defaultdict
from time import time
import collections
import contextlib
import functools
import io
import re
import sys
import warnings
def _get_screen_value(attrname, default=0):
"""Return the width or height of the terminal that runs this program."""
try:
curses = import_curses(... | Return the width of the terminal that runs this program. Returns: An integer, the number of characters the screen is wide. Return 0 if the terminal cannot be initialized. |
3,192 | from collections import defaultdict
from time import time
import collections
import contextlib
import functools
import io
import re
import sys
import warnings
def _get_screen_value(attrname, default=0):
"""Return the width or height of the terminal that runs this program."""
try:
curses = import_curses(... | Return the height of the terminal that runs this program. Returns: An integer, the number of characters the screen is high. Return 0 if the terminal cannot be initialized. |
3,193 | from collections import defaultdict
from time import time
import collections
import contextlib
import functools
import io
import re
import sys
import warnings
class TypeComparable:
"""A base class whose equality comparison includes comparing the
type of the instance itself.
"""
def __eq__(self, other):
... | Manufacture a comparable namedtuple class, similar to collections.namedtuple. A comparable named tuple is a tuple which compares to False if contents are equal but the data types are different. We define this to supplement collections.namedtuple because by default a namedtuple disregards the type and we want to make pr... |
3,194 | from collections import defaultdict
from time import time
import collections
import contextlib
import functools
import io
import re
import sys
import warnings
The provided code snippet includes necessary dependencies for implementing the `is_sorted` function. Write a Python function `def is_sorted(iterable, key=lambda... | Return true if the sequence is sorted. Args: iterable: An iterable sequence. key: A function to extract the quantity by which to sort. cmp: A function that compares two elements of a sequence. Returns: A boolean, true if the sequence is sorted. |
3,195 | import shelve
import threading
import hashlib
import datetime
import functools
import io
def now():
"Indirection on datetime.datetime.now() for testing."
return datetime.datetime.now()
The provided code snippet includes necessary dependencies for implementing the `memoize_recent_fileobj` function. Write a Pyth... | Memoize recent calls to the given function which returns a file object. The results of the cache expire after some time. Args: function: A callable object. cache_filename: A string, the path to the database file to cache to. expiration: The time during which the results will be kept valid. Use 'None' to never expire th... |
3,196 | import re
import subprocess
from os import path
The provided code snippet includes necessary dependencies for implementing the `is_gpg_installed` function. Write a Python function `def is_gpg_installed()` to solve the following problem:
Return true if GPG 1.4.x or 2.x are installed, which is what we use and support.
... | Return true if GPG 1.4.x or 2.x are installed, which is what we use and support. |
3,197 | import collections
import functools
import threading
The provided code snippet includes necessary dependencies for implementing the `snoopify` function. Write a Python function `def snoopify(function)` to solve the following problem:
Decorate a function as snoopable. This is meant to reassign existing functions to a s... | Decorate a function as snoopable. This is meant to reassign existing functions to a snoopable version of them. For example, if you wanted 're.match' to be automatically snoopable, just decorate it like this: re.match = snoopify(re.match) and then you can just call 're.match' in a conditional and then access 're.match.v... |
3,198 | import importlib
The provided code snippet includes necessary dependencies for implementing the `import_symbol` function. Write a Python function `def import_symbol(dotted_name)` to solve the following problem:
Import a symbol in an arbitrary module. Args: dotted_name: A dotted path to a symbol. Returns: The object re... | Import a symbol in an arbitrary module. Args: dotted_name: A dotted path to a symbol. Returns: The object referenced by the given name. Raises: ImportError: If the module not not be imported. AttributeError: If the symbol could not be found in the module. |
3,199 | import contextlib
import datetime
import os
import time
The provided code snippet includes necessary dependencies for implementing the `iter_dates` function. Write a Python function `def iter_dates(start_date, end_date)` to solve the following problem:
Yield all the dates between 'start_date' and 'end_date'. Args: sta... | Yield all the dates between 'start_date' and 'end_date'. Args: start_date: An instance of datetime.date. end_date: An instance of datetime.date. Yields: Instances of datetime.date. |
3,200 | import contextlib
import datetime
import os
import time
The provided code snippet includes necessary dependencies for implementing the `render_ofx_date` function. Write a Python function `def render_ofx_date(dtime)` to solve the following problem:
Render a datetime to the OFX format. Args: dtime: A datetime.datetime i... | Render a datetime to the OFX format. Args: dtime: A datetime.datetime instance. Returns: A string, rendered to milliseconds. |
3,201 | import contextlib
import datetime
import os
import time
The provided code snippet includes necessary dependencies for implementing the `next_month` function. Write a Python function `def next_month(date)` to solve the following problem:
Compute the date at the beginning of the following month from the given date. Args... | Compute the date at the beginning of the following month from the given date. Args: date: A datetime.date instance. Returns: A datetime.date instance, the first day of the month following 'date'. |
3,202 | import contextlib
import datetime
import os
import time
The provided code snippet includes necessary dependencies for implementing the `intimezone` function. Write a Python function `def intimezone(tz_value: str)` to solve the following problem:
Temporarily reset the value of TZ. This is used for testing. Args: tz_val... | Temporarily reset the value of TZ. This is used for testing. Args: tz_value: The value of TZ to set for the duration of this context. Returns: A contextmanager in the given timezone locale. |
3,203 | from os import path
import contextlib
import logging
import os
import time
The provided code snippet includes necessary dependencies for implementing the `find_files` function. Write a Python function `def find_files(fords, ignore_dirs=('.hg', '.svn', '.git'), ignore_files=('.DS_Store',))... | Enumerate the files under the given directories, stably. Invalid file or directory names will be logged to the error log. Args: fords: A list of strings, file or directory names. ignore_dirs: A list of strings, filenames or directories to be ignored. Yields: Strings, full filenames from the given roots. |
3,204 | from os import path
import contextlib
import logging
import os
import time
The provided code snippet includes necessary dependencies for implementing the `guess_file_format` function. Write a Python function `def guess_file_format(filename, default=None)` to solve the following problem:
Guess the file format from the ... | Guess the file format from the filename. Args: filename: A string, the name of the file. This can be None. Returns: A string, the extension of the format, without a leading period. |
3,205 | from os import path
import contextlib
import logging
import os
import time
The provided code snippet includes necessary dependencies for implementing the `path_greedy_split` function. Write a Python function `def path_greedy_split(filename)` to solve the following problem:
Split a path, returning the longest possible ... | Split a path, returning the longest possible extension. Args: filename: A string, the filename to split. Returns: A pair of basename, extension (which includes the leading period). |
3,206 | from os import path
import contextlib
import logging
import os
import time
The provided code snippet includes necessary dependencies for implementing the `touch_file` function. Write a Python function `def touch_file(filename, *otherfiles)` to solve the following problem:
Touch a file and wait until its timestamp has ... | Touch a file and wait until its timestamp has been changed. Args: filename: A string path, the name of the file to touch. otherfiles: A list of other files to ensure the timestamp is beyond of. |
3,207 | import csv
import collections
import io
import itertools
Table = collections.namedtuple('Table', 'columns header body')
def attribute_to_title(fieldname):
"""Convert programming id into readable field name.
Args:
fieldname: A string, a programming ids, such as 'book_value'.
Returns:
A readable s... | Convert a list of tuples to an table report object. Args: rows: A list of tuples. field_spec: A list of strings, or a list of (FIELDNAME-OR-INDEX, HEADER, FORMATTER-FUNCTION) triplets, that selects a subset of the fields is to be rendered as well as their ordering. If this is a dict, the values are functions to call on... |
3,208 | import csv
import collections
import io
import itertools
def table_to_html(table, classes=None, file=None):
"""Render a Table to HTML.
Args:
table: An instance of a Table.
classes: A list of string, CSS classes to set on the table.
file: A file object to write to. If no object is provided, thi... | Render the given table to the output file object in the requested format. The table gets written out to the 'output' file. Args: table_: An instance of Table. output: A file object you can write to. output_format: A string, the format to write the table to, either 'csv', 'txt' or 'html'. css_id: A string, an optional C... |
3,209 | import codecs
import contextlib
import os
import sys
import subprocess
import io
import logging
DEFAULT_PAGER = 'more'
The provided code snippet includes necessary dependencies for implementing the `create_pager` function. Write a Python function `def create_pager(command, file)` to solve the following problem:
Try to... | Try to create and return a pager subprocess. Args: command: A string, the shell command to run as a pager. file: The file object for the pager write to. This is also used as a default if we failed to create the pager subprocess. Returns: A pair of (file, pipe), a file object and an optional subprocess.Popen instance to... |
3,210 | import codecs
import contextlib
import os
import sys
import subprocess
import io
import logging
The provided code snippet includes necessary dependencies for implementing the `flush_only` function. Write a Python function `def flush_only(fileobj)` to solve the following problem:
A contextmanager around a file object t... | A contextmanager around a file object that does not close the file. This is used to return a context manager on a file object but not close it. We flush it instead. This is useful in order to provide an alternative to a pager class as above. Args: fileobj: A file object, to remain open after running the context manager... |
3,211 | import types
def invariant_check(method, prefun, postfun):
"""Decorate a method with the pre/post invariant checkers.
Args:
method: An unbound method to instrument.
prefun: A function that checks invariants pre-call.
postfun: A function that checks invariants post-call.
Returns:
An u... | Instrument the class 'klass' with pre/post invariant checker functions. Args: klass: A class object, whose methods to be instrumented. prefun: A function that checks invariants pre-call. postfun: A function that checks invariants pre-call. |
3,212 | import types
The provided code snippet includes necessary dependencies for implementing the `uninstrument_invariants` function. Write a Python function `def uninstrument_invariants(klass)` to solve the following problem:
Undo the instrumentation for invariants. Args: klass: A class object, whose methods to be uninstru... | Undo the instrumentation for invariants. Args: klass: A class object, whose methods to be uninstrumented. |
3,213 | import argparse
import collections
import logging
import os
import re
from os import path
def parse_htaccess(filename):
documents = collections.defaultdict(list)
redirects = []
with open(filename) as f:
for line in f:
match = re.match(r'RedirectMatch /doc/(.+?)\$\s+(.+)$', line)
if ma... | null |
3,214 | import argparse
import bisect
import csv
import collections
import logging
import math
import random
import re
import textwrap
from os import path
from beancount.core.number import D
from beancount.core import amount
def groupby(sequence, key):
groups = collections.defaultdict(list)
for el in sequence:
... | null |
3,215 | import argparse
import bisect
import csv
import collections
import logging
import math
import random
import re
import textwrap
from os import path
from beancount.core.number import D
from beancount.core import amount
def create_txns(p, x, x_end, all_lines, boxes, pr):
# Note: Side-effects on 'boxes'.
while x <=... | null |
3,216 | from decimal import Decimal
from os import path
import argparse
import datetime
import functools
import itertools
import logging
import re
from typing import Optional
try:
import riegeli
except ImportError:
riegeli = None
from google.protobuf import text_format
from beancount import loader
from beancount.parser... | null |
3,217 | from decimal import Decimal
from os import path
import argparse
import datetime
import functools
import itertools
import logging
import re
from typing import Optional
from google.protobuf import text_format
from beancount import loader
from beancount.parser import parser
from beancount.parser import printer
from beanco... | null |
3,218 | import sqlite3 as dbapi
import logging
import sys
import os
import itertools
from os import path
from decimal import Decimal
import click
from beancount import loader
from beancount.core import data
from beancount.utils import misc_utils
from beancount.parser.version import VERSION
The provided code snippet includes n... | Create a table of common data for all entries. Args: connection: A DBAPI-2.0 Connection object. entries: A list of directives. |
3,219 | import sqlite3 as dbapi
import logging
import sys
import os
import itertools
from os import path
from decimal import Decimal
import click
from beancount import loader
from beancount.core import data
from beancount.utils import misc_utils
from beancount.parser.version import VERSION
The provided code snippet includes n... | Create a table for transactions and fill in the data. Args: connection: A DBAPI-2.0 Connection object. entries: A list of directives. |
3,220 | import sqlite3 as dbapi
import logging
import sys
import os
import itertools
from os import path
from decimal import Decimal
import click
from beancount import loader
from beancount.core import data
from beancount.utils import misc_utils
from beancount.parser.version import VERSION
def adapt_decimal(number):
"""Ada... | Setup sqlite3 to support conversions to/from Decimal numbers. |
3,221 | from os import path
import argparse
import datetime
import hashlib
import json
import logging
import os
import pickle
import re
import shelve
import shutil
import subprocess
import tempfile
import urllib.parse
from typing import List
import bs4
import apiclient.errors
from apiclient import discovery
import httplib2
fro... | null |
3,222 | from os import path
import argparse
import datetime
import hashlib
import json
import logging
import os
import pickle
import re
import shelve
import shutil
import subprocess
import tempfile
import urllib.parse
from typing import List
import bs4
import apiclient.errors
from apiclient import discovery
import httplib2
fro... | Given a files service, get the doc list of doc ids from the index page. |
3,223 | from os import path
import argparse
import datetime
import hashlib
import json
import logging
import os
import pickle
import re
import shelve
import shutil
import subprocess
import tempfile
import urllib.parse
from typing import List
import bs4
import apiclient.errors
from apiclient import discovery
import httplib2
fro... | Get an authenticated http object via a service account. Args: scopes: A string or a list of strings, the scopes to get credentials for. Returns: A pair or (credentials, http) objects, where 'http' is an authenticated http client object, from which you can use the Google APIs. |
3,224 | import argparse
import logging
import zipfile
import io
import re
import os
import threading
import subprocess
from os import path
from typing import List
from typing import Tuple
from pprint import pprint
import bs4
def ConvertToMarkdown(text: str, isbold: bool, isitalic: bool):
text = text.replace('*', r'\*')
... | null |
3,225 | import argparse
import logging
import zipfile
import io
import re
import os
import threading
import subprocess
from os import path
from typing import List
from typing import Tuple
from pprint import pprint
import bs4
save = _Save()
The provided code snippet includes necessary dependencies for implementing the `GetMark... | Get the list of blockquotes from the markdown file (and their positions). |
3,226 | import argparse
import logging
import zipfile
import io
import re
import os
import threading
import subprocess
from os import path
from typing import List
from typing import Tuple
from pprint import pprint
import bs4
def ConvertToRst(text: str, isbold: bool, isitalic: bool):
text = text.replace('*', r'\*')
if i... | null |
3,227 | import argparse
import logging
import zipfile
import io
import re
import os
import threading
import subprocess
from os import path
from typing import List
from typing import Tuple
from pprint import pprint
import bs4
def FindDocxFiles(root: str):
if path.isdir(root):
for root, _, files in os.walk(root):
... | null |
3,228 | import logging
import os
import subprocess
import re
import pickle
import hashlib
import shelve
from os import path
import httplib2
from oauth2client import service_account
The provided code snippet includes necessary dependencies for implementing the `find_index_document` function. Write a Python function `def find_i... | Find the document of Beancount index. Args: files: A Cached API client object with Google Drive scope. Returns: A string, the document id. |
3,229 | import logging
import os
import subprocess
import re
import pickle
import hashlib
import shelve
from os import path
import httplib2
from oauth2client import service_account
The provided code snippet includes necessary dependencies for implementing the `enumerate_linked_documents` function. Write a Python function `def... | Given a document id, enumerate the links within it. Args: files: A Cached API client object with Google Drive scope. indexid: A string, a document id. Returns: A list of link strings. |
3,230 | import logging
import os
import subprocess
import re
import pickle
import hashlib
import shelve
from os import path
import httplib2
from oauth2client import service_account
CONVERSION_MAP = {
'html': ('text/html', None),
'txt': ('text/plain', None),
'rtf': ('application/rtf', None),
'pdf': ('application... | Download all the Beancount documents to a temporary directory. Args: files: A Cached API client object with Google Drive scope. docids: A list of string, the document ids to download. outdir: A string, the name of the directory where to store the files. extension: A string, the extension of the requested documents. Ret... |
3,231 | import logging
import os
import subprocess
import re
import pickle
import hashlib
import shelve
from os import path
import httplib2
from oauth2client import service_account
def collate_pdf_filenames(filenames, output_filename):
"""Combine the list of PDF filenames together into a single file.
Args:
filena... | Process downloaded PDF files. Args: filenames: A list of filename strings. output_filename: A string, the name of the output file. |
3,232 | import logging
import os
import subprocess
import re
import pickle
import hashlib
import shelve
from os import path
import httplib2
from oauth2client import service_account
SERVICE_ACCOUNT_FILE = path.join(os.environ['HOME'],
'.google-apis-service-account.json')
The provided code snipp... | Get an authenticated http object via a service account. Args: scopes: A string or a list of strings, the scopes to get credentials for. Returns: A pair or (credentials, http) objects, where 'http' is an authenticated http client object, from which you can use the Google APIs. |
3,233 | import argparse
import logging
import os
import tempfile
import subprocess
import tempfile
from os import path
from apiclient import discovery
import docs
def pandoc(filename, informat):
cwd = path.dirname(path.abspath(__file__))
command = [
'pandoc', '-f', informat, '-t', 'markdown',
'--filter... | null |
3,234 | import sys
import pandocfilters
def caps(key, value, format, meta):
if key == 'BlockQuote':
print(value, file=sys.stderr) | null |
3,235 | import os
import re
from os import path
BEANCOUNT_DIR = os.environ.get("BEANCOUNT_DIR",
path.expanduser("~/.beancount"))
The provided code snippet includes necessary dependencies for implementing the `get_file` function. Write a Python function `def get_file(filename)` to solve the follo... | Return a filename ensuring its parent directory. Args: filename: A string, the filename. If the filename is relative, it is created relative to BEANCOUNT_DIR. |
3,236 | from os import path
import argparse
import textwrap
import datetime
import hashlib
import collections
import json
import logging
import os
import pickle
import pprint
import re
import shelve
import shutil
import subprocess
import tempfile
import urllib.parse
from typing import List
import bs4
import apiclient.errors
fr... | null |
3,237 | from os import path
import argparse
import textwrap
import datetime
import hashlib
import collections
import json
import logging
import os
import pickle
import pprint
import re
import shelve
import shutil
import subprocess
import tempfile
import urllib.parse
from typing import List
import bs4
import apiclient.errors
fr... | null |
3,238 | from os import path
import argparse
import textwrap
import datetime
import hashlib
import collections
import json
import logging
import os
import pickle
import pprint
import re
import shelve
import shutil
import subprocess
import tempfile
import urllib.parse
from typing import List
import bs4
import apiclient.errors
fr... | null |
3,239 | from os import path
import argparse
import textwrap
import datetime
import hashlib
import collections
import json
import logging
import os
import pickle
import pprint
import re
import shelve
import shutil
import subprocess
import tempfile
import urllib.parse
from typing import List
import bs4
import apiclient.errors
fr... | null |
3,240 | from os import path
import argparse
import textwrap
import datetime
import hashlib
import collections
import json
import logging
import os
import pickle
import pprint
import re
import shelve
import shutil
import subprocess
import tempfile
import urllib.parse
from typing import List
import bs4
import apiclient.errors
fr... | null |
3,241 | from os import path
import argparse
import textwrap
import datetime
import hashlib
import collections
import json
import logging
import os
import pickle
import pprint
import re
import shelve
import shutil
import subprocess
import tempfile
import urllib.parse
from typing import List
import bs4
import apiclient.errors
fr... | null |
3,242 | from os import path
import argparse
import textwrap
import datetime
import hashlib
import collections
import json
import logging
import os
import pickle
import pprint
import re
import shelve
import shutil
import subprocess
import tempfile
import urllib.parse
from typing import List
import bs4
import apiclient.errors
fr... | null |
3,243 | from os import path
import argparse
import textwrap
import datetime
import hashlib
import collections
import json
import logging
import os
import pickle
import pprint
import re
import shelve
import shutil
import subprocess
import tempfile
import urllib.parse
from typing import List
import bs4
import apiclient.errors
fr... | null |
3,244 | from os import path
import argparse
import textwrap
import datetime
import hashlib
import collections
import json
import logging
import os
import pickle
import pprint
import re
import shelve
import shutil
import subprocess
import tempfile
import urllib.parse
from typing import List
import bs4
import apiclient.errors
fr... | null |
3,245 | from os import path
import argparse
import textwrap
import datetime
import hashlib
import collections
import json
import logging
import os
import pickle
import pprint
import re
import shelve
import shutil
import subprocess
import tempfile
import urllib.parse
from typing import List
import bs4
import apiclient.errors
fr... | null |
3,246 | from os import path
import argparse
import textwrap
import datetime
import hashlib
import collections
import json
import logging
import os
import pickle
import pprint
import re
import shelve
import shutil
import subprocess
import tempfile
import urllib.parse
from typing import List
import bs4
import apiclient.errors
fr... | null |
3,247 | from os import path
import argparse
import textwrap
import datetime
import hashlib
import collections
import json
import logging
import os
import pickle
import pprint
import re
import shelve
import shutil
import subprocess
import tempfile
import urllib.parse
from typing import List
import bs4
import apiclient.errors
fr... | null |
3,248 | from os import path
import argparse
import textwrap
import datetime
import hashlib
import collections
import json
import logging
import os
import pickle
import pprint
import re
import shelve
import shutil
import subprocess
import tempfile
import urllib.parse
from typing import List
import bs4
import apiclient.errors
fr... | null |
3,249 | from os import path
import argparse
import textwrap
import datetime
import hashlib
import collections
import json
import logging
import os
import pickle
import pprint
import re
import shelve
import shutil
import subprocess
import tempfile
import urllib.parse
from typing import List
import bs4
import apiclient.errors
fr... | Remove text runs with the default font. |
3,250 | from os import path
import argparse
import textwrap
import datetime
import hashlib
import collections
import json
import logging
import os
import pickle
import pprint
import re
import shelve
import shutil
import subprocess
import tempfile
import urllib.parse
from typing import List
import bs4
import apiclient.errors
fr... | Merge consecutive text runs with the same font. |
3,251 | from os import path
import argparse
import re
import textwrap
def get_deps(filename):
deps = set()
for line in open(filename):
if 'beancount' not in line:
continue
line = re.sub(r" as (.*)$", "", line)
dep = None
match = re.match(r"from (.*) import (.*)$", line)
... | null |
3,252 | from os import path
import argparse
import re
import textwrap
def render(filename, deps):
basename = path.basename(filename)
name = basename.replace(".py", "")
target = "py_test" if re.search(r"_test.py$", basename) else "py_library"
print(textwrap.dedent(f"""\
{target}(
name = "{na... | null |
3,253 | from typing import List, Optional, Dict, Any, Mapping, Iterator, Callable, Tuple
import argparse
import json
import functools
import re
from googleapiclient import discovery
from beancount.tools import gapis
def iter_links(document: Json) -> List[Tuple[str, str]]:
"""Find all the links and return them."""
for ... | Run the link transformation. |
3,254 | import argparse
import logging
import re
import os
from os import path
from apiclient import discovery
import httplib2
from apiclient.http import MediaInMemoryUpload
from oauth2client import service_account
from beancount.parser import options
from beancount.utils import test_utils
The provided code snippet includes n... | Upload new contents for a Google Doc for a plain/text file. Args: http: An http connection object with drive credentials. docid: A string, the ID of the document. title: A string, the title of the document. contents: A string, the body of the document. |
3,255 | import argparse
import logging
import re
import os
from os import path
from apiclient import discovery
import httplib2
from apiclient.http import MediaInMemoryUpload
from oauth2client import service_account
from beancount.parser import options
from beancount.utils import test_utils
The provided code snippet includes n... | Find the options doc id from the redirect file. Returns: The id of the doc to fix up. |
3,256 | import argparse
import logging
import re
import os
from os import path
from apiclient import discovery
import httplib2
from apiclient.http import MediaInMemoryUpload
from oauth2client import service_account
from beancount.parser import options
from beancount.utils import test_utils
SERVICE_ACCOUNT_FILE = os.path.expand... | Get an authenticated http object via a service account. Args: scopes: A string or a list of strings, the scopes to get credentials for. Returns: A pair or (credentials, http) objects, where 'http' is an authenticated http client object, from which you can use the Google APIs. |
3,257 | import ast
import os
import argparse
import logging
import sys
from os import path
def find_files(rootdir):
if path.isfile(rootdir):
yield rootdir
for root, dirs, files in os.walk(rootdir):
for filename in files:
if filename.endswith('.py'):
yield path.join(root, fil... | null |
3,258 | import ast
import os
import argparse
import logging
import sys
from os import path
def get_name(node):
if isinstance(node, ast.Name):
return node.id
elif isinstance(node, ast.Attribute):
return node.attr | null |
3,259 | import sys
import argparse
import logging
def gen_inputs(template, args):
for mask in range(2 ** len(args)):
actual_args = [arg if not (1<<i & mask) else ''
for i, arg in enumerate(args)]
sys.stdout.write(template.format(*actual_args)) | null |
3,260 | import argparse
import logging
import os
import shutil
import tempfile
import subprocess
from os import path
OVERLAY_DOCS = {
'Beancount-Motivation' : 'cookbook/cl_cookbook.rst',
'Beancount-Trading_with_Beancount' : 'cookbook/trading.rst',
'Beancount-Cookbook-Vesting' : 'cookbook/... | Process downloaded OpenOffice files to reStructuredText. Args: inputdir: The name of an input directory with ODT files. sphinxdir: A string, the name of the beancount-docs directory. |
3,261 | import sys
import unicodedata
import argparse
from itertools import count, groupby
from collections import defaultdict
The provided code snippet includes necessary dependencies for implementing the `categorize_unicode` function. Write a Python function `def categorize_unicode()` to solve the following problem:
Return ... | Return a dictionary mapping Unicode general category names to the characters that belong to them. |
3,262 | import sys
import unicodedata
import argparse
from itertools import count, groupby
from collections import defaultdict
def groupby_sequences(iterable, keyfunc):
"""
Group items of iterable in groups such that the result of applying keyfunc
to them is consecutive.
"""
if keyfunc is None:
keyf... | Convert a set of characters into an string to be used in a Python regular expression's bracket expression (e.g. \u0062\u0064-\u006f). |
3,263 | import sys
import unicodedata
import argparse
from itertools import count, groupby
from collections import defaultdict
def list_chunks(l, n):
"""Split list in chunks of size n."""
for it in range(0, len(l), n):
yield l[it:it+n]
def groupby_sequences(iterable, keyfunc):
"""
Group items of iterabl... | Convert a set of characters into a string to be used in a lex regular expression |
3,264 | import argparse
import os
import subprocess
The provided code snippet includes necessary dependencies for implementing the `prevent_run_with_changes` function. Write a Python function `def prevent_run_with_changes()` to solve the following problem:
Fail if some local changes exist.
Here is the function:
def prevent_... | Fail if some local changes exist. |
3,265 | import argparse
import os
import subprocess
The provided code snippet includes necessary dependencies for implementing the `benchmark_revision` function. Write a Python function `def benchmark_revision(beancount_file: str, revision: str)` to solve the following problem:
Run the benchmark on a particular revision.
Her... | Run the benchmark on a particular revision. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.