repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 75 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
aio-libs/aiomcache | aiomcache/pool.py | MemcachePool.acquire | def acquire(self):
"""Acquire connection from the pool, or spawn new one
if pool maxsize permits.
:return: ``tuple`` (reader, writer)
"""
while self.size() == 0 or self.size() < self._minsize:
_conn = yield from self._create_new_conn()
if _conn is None:
... | python | def acquire(self):
"""Acquire connection from the pool, or spawn new one
if pool maxsize permits.
:return: ``tuple`` (reader, writer)
"""
while self.size() == 0 or self.size() < self._minsize:
_conn = yield from self._create_new_conn()
if _conn is None:
... | [
"def",
"acquire",
"(",
"self",
")",
":",
"while",
"self",
".",
"size",
"(",
")",
"==",
"0",
"or",
"self",
".",
"size",
"(",
")",
"<",
"self",
".",
"_minsize",
":",
"_conn",
"=",
"yield",
"from",
"self",
".",
"_create_new_conn",
"(",
")",
"if",
"_... | Acquire connection from the pool, or spawn new one
if pool maxsize permits.
:return: ``tuple`` (reader, writer) | [
"Acquire",
"connection",
"from",
"the",
"pool",
"or",
"spawn",
"new",
"one",
"if",
"pool",
"maxsize",
"permits",
"."
] | 75d44b201aea91bc2856b10940922d5ebfbfcd7b | https://github.com/aio-libs/aiomcache/blob/75d44b201aea91bc2856b10940922d5ebfbfcd7b/aiomcache/pool.py#L34-L56 | train |
aio-libs/aiomcache | aiomcache/pool.py | MemcachePool.release | def release(self, conn):
"""Releases connection back to the pool.
:param conn: ``namedtuple`` (reader, writer)
"""
self._in_use.remove(conn)
if conn.reader.at_eof() or conn.reader.exception():
self._do_close(conn)
else:
self._pool.put_nowait(conn) | python | def release(self, conn):
"""Releases connection back to the pool.
:param conn: ``namedtuple`` (reader, writer)
"""
self._in_use.remove(conn)
if conn.reader.at_eof() or conn.reader.exception():
self._do_close(conn)
else:
self._pool.put_nowait(conn) | [
"def",
"release",
"(",
"self",
",",
"conn",
")",
":",
"self",
".",
"_in_use",
".",
"remove",
"(",
"conn",
")",
"if",
"conn",
".",
"reader",
".",
"at_eof",
"(",
")",
"or",
"conn",
".",
"reader",
".",
"exception",
"(",
")",
":",
"self",
".",
"_do_c... | Releases connection back to the pool.
:param conn: ``namedtuple`` (reader, writer) | [
"Releases",
"connection",
"back",
"to",
"the",
"pool",
"."
] | 75d44b201aea91bc2856b10940922d5ebfbfcd7b | https://github.com/aio-libs/aiomcache/blob/75d44b201aea91bc2856b10940922d5ebfbfcd7b/aiomcache/pool.py#L58-L67 | train |
aio-libs/aiomcache | aiomcache/client.py | Client.get | def get(self, conn, key, default=None):
"""Gets a single value from the server.
:param key: ``bytes``, is the key for the item being fetched
:param default: default value if there is no value.
:return: ``bytes``, is the data for this specified key.
"""
values, _ = yield ... | python | def get(self, conn, key, default=None):
"""Gets a single value from the server.
:param key: ``bytes``, is the key for the item being fetched
:param default: default value if there is no value.
:return: ``bytes``, is the data for this specified key.
"""
values, _ = yield ... | [
"def",
"get",
"(",
"self",
",",
"conn",
",",
"key",
",",
"default",
"=",
"None",
")",
":",
"values",
",",
"_",
"=",
"yield",
"from",
"self",
".",
"_multi_get",
"(",
"conn",
",",
"key",
")",
"return",
"values",
".",
"get",
"(",
"key",
",",
"defaul... | Gets a single value from the server.
:param key: ``bytes``, is the key for the item being fetched
:param default: default value if there is no value.
:return: ``bytes``, is the data for this specified key. | [
"Gets",
"a",
"single",
"value",
"from",
"the",
"server",
"."
] | 75d44b201aea91bc2856b10940922d5ebfbfcd7b | https://github.com/aio-libs/aiomcache/blob/75d44b201aea91bc2856b10940922d5ebfbfcd7b/aiomcache/client.py#L142-L150 | train |
aio-libs/aiomcache | aiomcache/client.py | Client.gets | def gets(self, conn, key, default=None):
"""Gets a single value from the server together with the cas token.
:param key: ``bytes``, is the key for the item being fetched
:param default: default value if there is no value.
:return: ``bytes``, ``bytes tuple with the value and the cas
... | python | def gets(self, conn, key, default=None):
"""Gets a single value from the server together with the cas token.
:param key: ``bytes``, is the key for the item being fetched
:param default: default value if there is no value.
:return: ``bytes``, ``bytes tuple with the value and the cas
... | [
"def",
"gets",
"(",
"self",
",",
"conn",
",",
"key",
",",
"default",
"=",
"None",
")",
":",
"values",
",",
"cas_tokens",
"=",
"yield",
"from",
"self",
".",
"_multi_get",
"(",
"conn",
",",
"key",
",",
"with_cas",
"=",
"True",
")",
"return",
"values",
... | Gets a single value from the server together with the cas token.
:param key: ``bytes``, is the key for the item being fetched
:param default: default value if there is no value.
:return: ``bytes``, ``bytes tuple with the value and the cas | [
"Gets",
"a",
"single",
"value",
"from",
"the",
"server",
"together",
"with",
"the",
"cas",
"token",
"."
] | 75d44b201aea91bc2856b10940922d5ebfbfcd7b | https://github.com/aio-libs/aiomcache/blob/75d44b201aea91bc2856b10940922d5ebfbfcd7b/aiomcache/client.py#L153-L162 | train |
aio-libs/aiomcache | aiomcache/client.py | Client.multi_get | def multi_get(self, conn, *keys):
"""Takes a list of keys and returns a list of values.
:param keys: ``list`` keys for the item being fetched.
:return: ``list`` of values for the specified keys.
:raises:``ValidationException``, ``ClientException``,
and socket errors
"""
... | python | def multi_get(self, conn, *keys):
"""Takes a list of keys and returns a list of values.
:param keys: ``list`` keys for the item being fetched.
:return: ``list`` of values for the specified keys.
:raises:``ValidationException``, ``ClientException``,
and socket errors
"""
... | [
"def",
"multi_get",
"(",
"self",
",",
"conn",
",",
"*",
"keys",
")",
":",
"values",
",",
"_",
"=",
"yield",
"from",
"self",
".",
"_multi_get",
"(",
"conn",
",",
"*",
"keys",
")",
"return",
"tuple",
"(",
"values",
".",
"get",
"(",
"key",
")",
"for... | Takes a list of keys and returns a list of values.
:param keys: ``list`` keys for the item being fetched.
:return: ``list`` of values for the specified keys.
:raises:``ValidationException``, ``ClientException``,
and socket errors | [
"Takes",
"a",
"list",
"of",
"keys",
"and",
"returns",
"a",
"list",
"of",
"values",
"."
] | 75d44b201aea91bc2856b10940922d5ebfbfcd7b | https://github.com/aio-libs/aiomcache/blob/75d44b201aea91bc2856b10940922d5ebfbfcd7b/aiomcache/client.py#L165-L174 | train |
aio-libs/aiomcache | aiomcache/client.py | Client.stats | def stats(self, conn, args=None):
"""Runs a stats command on the server."""
# req - stats [additional args]\r\n
# resp - STAT <name> <value>\r\n (one per result)
# END\r\n
if args is None:
args = b''
conn.writer.write(b''.join((b'stats ', args, b'\r\n... | python | def stats(self, conn, args=None):
"""Runs a stats command on the server."""
# req - stats [additional args]\r\n
# resp - STAT <name> <value>\r\n (one per result)
# END\r\n
if args is None:
args = b''
conn.writer.write(b''.join((b'stats ', args, b'\r\n... | [
"def",
"stats",
"(",
"self",
",",
"conn",
",",
"args",
"=",
"None",
")",
":",
"if",
"args",
"is",
"None",
":",
"args",
"=",
"b''",
"conn",
".",
"writer",
".",
"write",
"(",
"b''",
".",
"join",
"(",
"(",
"b'stats '",
",",
"args",
",",
"b'\\r\\n'",... | Runs a stats command on the server. | [
"Runs",
"a",
"stats",
"command",
"on",
"the",
"server",
"."
] | 75d44b201aea91bc2856b10940922d5ebfbfcd7b | https://github.com/aio-libs/aiomcache/blob/75d44b201aea91bc2856b10940922d5ebfbfcd7b/aiomcache/client.py#L177-L204 | train |
aio-libs/aiomcache | aiomcache/client.py | Client.append | def append(self, conn, key, value, exptime=0):
"""Add data to an existing key after existing data
:param key: ``bytes``, is the key of the item.
:param value: ``bytes``, data to store.
:param exptime: ``int`` is expiration time. If it's 0, the
item never expires.
:retur... | python | def append(self, conn, key, value, exptime=0):
"""Add data to an existing key after existing data
:param key: ``bytes``, is the key of the item.
:param value: ``bytes``, data to store.
:param exptime: ``int`` is expiration time. If it's 0, the
item never expires.
:retur... | [
"def",
"append",
"(",
"self",
",",
"conn",
",",
"key",
",",
"value",
",",
"exptime",
"=",
"0",
")",
":",
"flags",
"=",
"0",
"return",
"(",
"yield",
"from",
"self",
".",
"_storage_command",
"(",
"conn",
",",
"b'append'",
",",
"key",
",",
"value",
",... | Add data to an existing key after existing data
:param key: ``bytes``, is the key of the item.
:param value: ``bytes``, data to store.
:param exptime: ``int`` is expiration time. If it's 0, the
item never expires.
:return: ``bool``, True in case of success. | [
"Add",
"data",
"to",
"an",
"existing",
"key",
"after",
"existing",
"data"
] | 75d44b201aea91bc2856b10940922d5ebfbfcd7b | https://github.com/aio-libs/aiomcache/blob/75d44b201aea91bc2856b10940922d5ebfbfcd7b/aiomcache/client.py#L305-L316 | train |
aio-libs/aiomcache | aiomcache/client.py | Client.prepend | def prepend(self, conn, key, value, exptime=0):
"""Add data to an existing key before existing data
:param key: ``bytes``, is the key of the item.
:param value: ``bytes``, data to store.
:param exptime: ``int`` is expiration time. If it's 0, the
item never expires.
:retu... | python | def prepend(self, conn, key, value, exptime=0):
"""Add data to an existing key before existing data
:param key: ``bytes``, is the key of the item.
:param value: ``bytes``, data to store.
:param exptime: ``int`` is expiration time. If it's 0, the
item never expires.
:retu... | [
"def",
"prepend",
"(",
"self",
",",
"conn",
",",
"key",
",",
"value",
",",
"exptime",
"=",
"0",
")",
":",
"flags",
"=",
"0",
"return",
"(",
"yield",
"from",
"self",
".",
"_storage_command",
"(",
"conn",
",",
"b'prepend'",
",",
"key",
",",
"value",
... | Add data to an existing key before existing data
:param key: ``bytes``, is the key of the item.
:param value: ``bytes``, data to store.
:param exptime: ``int`` is expiration time. If it's 0, the
item never expires.
:return: ``bool``, True in case of success. | [
"Add",
"data",
"to",
"an",
"existing",
"key",
"before",
"existing",
"data"
] | 75d44b201aea91bc2856b10940922d5ebfbfcd7b | https://github.com/aio-libs/aiomcache/blob/75d44b201aea91bc2856b10940922d5ebfbfcd7b/aiomcache/client.py#L319-L330 | train |
aio-libs/aiomcache | aiomcache/client.py | Client.incr | def incr(self, conn, key, increment=1):
"""Command is used to change data for some item in-place,
incrementing it. The data for the item is treated as decimal
representation of a 64-bit unsigned integer.
:param key: ``bytes``, is the key of the item the client wishes
to change
... | python | def incr(self, conn, key, increment=1):
"""Command is used to change data for some item in-place,
incrementing it. The data for the item is treated as decimal
representation of a 64-bit unsigned integer.
:param key: ``bytes``, is the key of the item the client wishes
to change
... | [
"def",
"incr",
"(",
"self",
",",
"conn",
",",
"key",
",",
"increment",
"=",
"1",
")",
":",
"assert",
"self",
".",
"_validate_key",
"(",
"key",
")",
"resp",
"=",
"yield",
"from",
"self",
".",
"_incr_decr",
"(",
"conn",
",",
"b'incr'",
",",
"key",
",... | Command is used to change data for some item in-place,
incrementing it. The data for the item is treated as decimal
representation of a 64-bit unsigned integer.
:param key: ``bytes``, is the key of the item the client wishes
to change
:param increment: ``int``, is the amount by ... | [
"Command",
"is",
"used",
"to",
"change",
"data",
"for",
"some",
"item",
"in",
"-",
"place",
"incrementing",
"it",
".",
"The",
"data",
"for",
"the",
"item",
"is",
"treated",
"as",
"decimal",
"representation",
"of",
"a",
"64",
"-",
"bit",
"unsigned",
"inte... | 75d44b201aea91bc2856b10940922d5ebfbfcd7b | https://github.com/aio-libs/aiomcache/blob/75d44b201aea91bc2856b10940922d5ebfbfcd7b/aiomcache/client.py#L343-L359 | train |
aio-libs/aiomcache | aiomcache/client.py | Client.decr | def decr(self, conn, key, decrement=1):
"""Command is used to change data for some item in-place,
decrementing it. The data for the item is treated as decimal
representation of a 64-bit unsigned integer.
:param key: ``bytes``, is the key of the item the client wishes
to change
... | python | def decr(self, conn, key, decrement=1):
"""Command is used to change data for some item in-place,
decrementing it. The data for the item is treated as decimal
representation of a 64-bit unsigned integer.
:param key: ``bytes``, is the key of the item the client wishes
to change
... | [
"def",
"decr",
"(",
"self",
",",
"conn",
",",
"key",
",",
"decrement",
"=",
"1",
")",
":",
"assert",
"self",
".",
"_validate_key",
"(",
"key",
")",
"resp",
"=",
"yield",
"from",
"self",
".",
"_incr_decr",
"(",
"conn",
",",
"b'decr'",
",",
"key",
",... | Command is used to change data for some item in-place,
decrementing it. The data for the item is treated as decimal
representation of a 64-bit unsigned integer.
:param key: ``bytes``, is the key of the item the client wishes
to change
:param decrement: ``int``, is the amount by ... | [
"Command",
"is",
"used",
"to",
"change",
"data",
"for",
"some",
"item",
"in",
"-",
"place",
"decrementing",
"it",
".",
"The",
"data",
"for",
"the",
"item",
"is",
"treated",
"as",
"decimal",
"representation",
"of",
"a",
"64",
"-",
"bit",
"unsigned",
"inte... | 75d44b201aea91bc2856b10940922d5ebfbfcd7b | https://github.com/aio-libs/aiomcache/blob/75d44b201aea91bc2856b10940922d5ebfbfcd7b/aiomcache/client.py#L362-L378 | train |
aio-libs/aiomcache | aiomcache/client.py | Client.touch | def touch(self, conn, key, exptime):
"""The command is used to update the expiration time of
an existing item without fetching it.
:param key: ``bytes``, is the key to update expiration time
:param exptime: ``int``, is expiration time. This replaces the existing
expiration time.... | python | def touch(self, conn, key, exptime):
"""The command is used to update the expiration time of
an existing item without fetching it.
:param key: ``bytes``, is the key to update expiration time
:param exptime: ``int``, is expiration time. This replaces the existing
expiration time.... | [
"def",
"touch",
"(",
"self",
",",
"conn",
",",
"key",
",",
"exptime",
")",
":",
"assert",
"self",
".",
"_validate_key",
"(",
"key",
")",
"_cmd",
"=",
"b' '",
".",
"join",
"(",
"[",
"b'touch'",
",",
"key",
",",
"str",
"(",
"exptime",
")",
".",
"en... | The command is used to update the expiration time of
an existing item without fetching it.
:param key: ``bytes``, is the key to update expiration time
:param exptime: ``int``, is expiration time. This replaces the existing
expiration time.
:return: ``bool``, True in case of succ... | [
"The",
"command",
"is",
"used",
"to",
"update",
"the",
"expiration",
"time",
"of",
"an",
"existing",
"item",
"without",
"fetching",
"it",
"."
] | 75d44b201aea91bc2856b10940922d5ebfbfcd7b | https://github.com/aio-libs/aiomcache/blob/75d44b201aea91bc2856b10940922d5ebfbfcd7b/aiomcache/client.py#L381-L397 | train |
aio-libs/aiomcache | aiomcache/client.py | Client.version | def version(self, conn):
"""Current version of the server.
:return: ``bytes``, memcached version for current the server.
"""
command = b'version\r\n'
response = yield from self._execute_simple_command(
conn, command)
if not response.startswith(const.VERSION)... | python | def version(self, conn):
"""Current version of the server.
:return: ``bytes``, memcached version for current the server.
"""
command = b'version\r\n'
response = yield from self._execute_simple_command(
conn, command)
if not response.startswith(const.VERSION)... | [
"def",
"version",
"(",
"self",
",",
"conn",
")",
":",
"command",
"=",
"b'version\\r\\n'",
"response",
"=",
"yield",
"from",
"self",
".",
"_execute_simple_command",
"(",
"conn",
",",
"command",
")",
"if",
"not",
"response",
".",
"startswith",
"(",
"const",
... | Current version of the server.
:return: ``bytes``, memcached version for current the server. | [
"Current",
"version",
"of",
"the",
"server",
"."
] | 75d44b201aea91bc2856b10940922d5ebfbfcd7b | https://github.com/aio-libs/aiomcache/blob/75d44b201aea91bc2856b10940922d5ebfbfcd7b/aiomcache/client.py#L400-L412 | train |
aio-libs/aiomcache | aiomcache/client.py | Client.flush_all | def flush_all(self, conn):
"""Its effect is to invalidate all existing items immediately"""
command = b'flush_all\r\n'
response = yield from self._execute_simple_command(
conn, command)
if const.OK != response:
raise ClientException('Memcached flush_all failed', ... | python | def flush_all(self, conn):
"""Its effect is to invalidate all existing items immediately"""
command = b'flush_all\r\n'
response = yield from self._execute_simple_command(
conn, command)
if const.OK != response:
raise ClientException('Memcached flush_all failed', ... | [
"def",
"flush_all",
"(",
"self",
",",
"conn",
")",
":",
"command",
"=",
"b'flush_all\\r\\n'",
"response",
"=",
"yield",
"from",
"self",
".",
"_execute_simple_command",
"(",
"conn",
",",
"command",
")",
"if",
"const",
".",
"OK",
"!=",
"response",
":",
"rais... | Its effect is to invalidate all existing items immediately | [
"Its",
"effect",
"is",
"to",
"invalidate",
"all",
"existing",
"items",
"immediately"
] | 75d44b201aea91bc2856b10940922d5ebfbfcd7b | https://github.com/aio-libs/aiomcache/blob/75d44b201aea91bc2856b10940922d5ebfbfcd7b/aiomcache/client.py#L415-L422 | train |
python273/telegraph | telegraph/api.py | Telegraph.create_account | def create_account(self, short_name, author_name=None, author_url=None,
replace_token=True):
""" Create a new Telegraph account
:param short_name: Account name, helps users with several
accounts remember which they are currently using.
... | python | def create_account(self, short_name, author_name=None, author_url=None,
replace_token=True):
""" Create a new Telegraph account
:param short_name: Account name, helps users with several
accounts remember which they are currently using.
... | [
"def",
"create_account",
"(",
"self",
",",
"short_name",
",",
"author_name",
"=",
"None",
",",
"author_url",
"=",
"None",
",",
"replace_token",
"=",
"True",
")",
":",
"response",
"=",
"self",
".",
"_telegraph",
".",
"method",
"(",
"'createAccount'",
",",
"... | Create a new Telegraph account
:param short_name: Account name, helps users with several
accounts remember which they are currently using.
Displayed to the user above the "Edit/Publish"
button on Telegra.ph, other users don't see ... | [
"Create",
"a",
"new",
"Telegraph",
"account"
] | 6d45cd6bbae4fdbd85b48ce32626f3c66e9e5ddc | https://github.com/python273/telegraph/blob/6d45cd6bbae4fdbd85b48ce32626f3c66e9e5ddc/telegraph/api.py#L57-L84 | train |
python273/telegraph | telegraph/api.py | Telegraph.edit_account_info | def edit_account_info(self, short_name=None, author_name=None,
author_url=None):
""" Update information about a Telegraph account.
Pass only the parameters that you want to edit
:param short_name: Account name, helps users with several
ac... | python | def edit_account_info(self, short_name=None, author_name=None,
author_url=None):
""" Update information about a Telegraph account.
Pass only the parameters that you want to edit
:param short_name: Account name, helps users with several
ac... | [
"def",
"edit_account_info",
"(",
"self",
",",
"short_name",
"=",
"None",
",",
"author_name",
"=",
"None",
",",
"author_url",
"=",
"None",
")",
":",
"return",
"self",
".",
"_telegraph",
".",
"method",
"(",
"'editAccountInfo'",
",",
"values",
"=",
"{",
"'sho... | Update information about a Telegraph account.
Pass only the parameters that you want to edit
:param short_name: Account name, helps users with several
accounts remember which they are currently using.
Displayed to the user above the "Edit/Publis... | [
"Update",
"information",
"about",
"a",
"Telegraph",
"account",
".",
"Pass",
"only",
"the",
"parameters",
"that",
"you",
"want",
"to",
"edit"
] | 6d45cd6bbae4fdbd85b48ce32626f3c66e9e5ddc | https://github.com/python273/telegraph/blob/6d45cd6bbae4fdbd85b48ce32626f3c66e9e5ddc/telegraph/api.py#L86-L107 | train |
python273/telegraph | telegraph/api.py | Telegraph.revoke_access_token | def revoke_access_token(self):
""" Revoke access_token and generate a new one, for example,
if the user would like to reset all connected sessions, or
you have reasons to believe the token was compromised.
On success, returns dict with new access_token and auth_url fields
... | python | def revoke_access_token(self):
""" Revoke access_token and generate a new one, for example,
if the user would like to reset all connected sessions, or
you have reasons to believe the token was compromised.
On success, returns dict with new access_token and auth_url fields
... | [
"def",
"revoke_access_token",
"(",
"self",
")",
":",
"response",
"=",
"self",
".",
"_telegraph",
".",
"method",
"(",
"'revokeAccessToken'",
")",
"self",
".",
"_telegraph",
".",
"access_token",
"=",
"response",
".",
"get",
"(",
"'access_token'",
")",
"return",
... | Revoke access_token and generate a new one, for example,
if the user would like to reset all connected sessions, or
you have reasons to believe the token was compromised.
On success, returns dict with new access_token and auth_url fields | [
"Revoke",
"access_token",
"and",
"generate",
"a",
"new",
"one",
"for",
"example",
"if",
"the",
"user",
"would",
"like",
"to",
"reset",
"all",
"connected",
"sessions",
"or",
"you",
"have",
"reasons",
"to",
"believe",
"the",
"token",
"was",
"compromised",
".",... | 6d45cd6bbae4fdbd85b48ce32626f3c66e9e5ddc | https://github.com/python273/telegraph/blob/6d45cd6bbae4fdbd85b48ce32626f3c66e9e5ddc/telegraph/api.py#L109-L120 | train |
python273/telegraph | telegraph/api.py | Telegraph.get_page | def get_page(self, path, return_content=True, return_html=True):
""" Get a Telegraph page
:param path: Path to the Telegraph page (in the format Title-12-31,
i.e. everything that comes after https://telegra.ph/)
:param return_content: If true, content field will be returne... | python | def get_page(self, path, return_content=True, return_html=True):
""" Get a Telegraph page
:param path: Path to the Telegraph page (in the format Title-12-31,
i.e. everything that comes after https://telegra.ph/)
:param return_content: If true, content field will be returne... | [
"def",
"get_page",
"(",
"self",
",",
"path",
",",
"return_content",
"=",
"True",
",",
"return_html",
"=",
"True",
")",
":",
"response",
"=",
"self",
".",
"_telegraph",
".",
"method",
"(",
"'getPage'",
",",
"path",
"=",
"path",
",",
"values",
"=",
"{",
... | Get a Telegraph page
:param path: Path to the Telegraph page (in the format Title-12-31,
i.e. everything that comes after https://telegra.ph/)
:param return_content: If true, content field will be returned
:param return_html: If true, returns HTML instead of Nodes list | [
"Get",
"a",
"Telegraph",
"page"
] | 6d45cd6bbae4fdbd85b48ce32626f3c66e9e5ddc | https://github.com/python273/telegraph/blob/6d45cd6bbae4fdbd85b48ce32626f3c66e9e5ddc/telegraph/api.py#L122-L139 | train |
python273/telegraph | telegraph/api.py | Telegraph.create_page | def create_page(self, title, content=None, html_content=None,
author_name=None, author_url=None, return_content=False):
""" Create a new Telegraph page
:param title: Page title
:param content: Content in nodes list format (see doc)
:param html_content: Content in H... | python | def create_page(self, title, content=None, html_content=None,
author_name=None, author_url=None, return_content=False):
""" Create a new Telegraph page
:param title: Page title
:param content: Content in nodes list format (see doc)
:param html_content: Content in H... | [
"def",
"create_page",
"(",
"self",
",",
"title",
",",
"content",
"=",
"None",
",",
"html_content",
"=",
"None",
",",
"author_name",
"=",
"None",
",",
"author_url",
"=",
"None",
",",
"return_content",
"=",
"False",
")",
":",
"if",
"content",
"is",
"None",... | Create a new Telegraph page
:param title: Page title
:param content: Content in nodes list format (see doc)
:param html_content: Content in HTML format
:param author_name: Author name, displayed below the article's title
:param author_url: Profile link, opened when users cli... | [
"Create",
"a",
"new",
"Telegraph",
"page"
] | 6d45cd6bbae4fdbd85b48ce32626f3c66e9e5ddc | https://github.com/python273/telegraph/blob/6d45cd6bbae4fdbd85b48ce32626f3c66e9e5ddc/telegraph/api.py#L141-L170 | train |
python273/telegraph | telegraph/api.py | Telegraph.get_account_info | def get_account_info(self, fields=None):
""" Get information about a Telegraph account
:param fields: List of account fields to return. Available fields:
short_name, author_name, author_url, auth_url, page_count
Default: [“short_name”,“author_name”,“author... | python | def get_account_info(self, fields=None):
""" Get information about a Telegraph account
:param fields: List of account fields to return. Available fields:
short_name, author_name, author_url, auth_url, page_count
Default: [“short_name”,“author_name”,“author... | [
"def",
"get_account_info",
"(",
"self",
",",
"fields",
"=",
"None",
")",
":",
"return",
"self",
".",
"_telegraph",
".",
"method",
"(",
"'getAccountInfo'",
",",
"{",
"'fields'",
":",
"json",
".",
"dumps",
"(",
"fields",
")",
"if",
"fields",
"else",
"None"... | Get information about a Telegraph account
:param fields: List of account fields to return. Available fields:
short_name, author_name, author_url, auth_url, page_count
Default: [“short_name”,“author_name”,“author_url”] | [
"Get",
"information",
"about",
"a",
"Telegraph",
"account"
] | 6d45cd6bbae4fdbd85b48ce32626f3c66e9e5ddc | https://github.com/python273/telegraph/blob/6d45cd6bbae4fdbd85b48ce32626f3c66e9e5ddc/telegraph/api.py#L205-L216 | train |
python273/telegraph | telegraph/api.py | Telegraph.get_views | def get_views(self, path, year=None, month=None, day=None, hour=None):
""" Get the number of views for a Telegraph article
:param path: Path to the Telegraph page
:param year: Required if month is passed. If passed, the number of
page views for the requested year will be r... | python | def get_views(self, path, year=None, month=None, day=None, hour=None):
""" Get the number of views for a Telegraph article
:param path: Path to the Telegraph page
:param year: Required if month is passed. If passed, the number of
page views for the requested year will be r... | [
"def",
"get_views",
"(",
"self",
",",
"path",
",",
"year",
"=",
"None",
",",
"month",
"=",
"None",
",",
"day",
"=",
"None",
",",
"hour",
"=",
"None",
")",
":",
"return",
"self",
".",
"_telegraph",
".",
"method",
"(",
"'getViews'",
",",
"path",
"=",... | Get the number of views for a Telegraph article
:param path: Path to the Telegraph page
:param year: Required if month is passed. If passed, the number of
page views for the requested year will be returned
:param month: Required if day is passed. If passed, the number of
... | [
"Get",
"the",
"number",
"of",
"views",
"for",
"a",
"Telegraph",
"article"
] | 6d45cd6bbae4fdbd85b48ce32626f3c66e9e5ddc | https://github.com/python273/telegraph/blob/6d45cd6bbae4fdbd85b48ce32626f3c66e9e5ddc/telegraph/api.py#L234-L257 | train |
python273/telegraph | telegraph/upload.py | upload_file | def upload_file(f):
""" Upload file to Telegra.ph's servers. Returns a list of links.
Allowed only .jpg, .jpeg, .png, .gif and .mp4 files.
:param f: filename or file-like object.
:type f: file, str or list
"""
with FilesOpener(f) as files:
response = requests.post(
'http... | python | def upload_file(f):
""" Upload file to Telegra.ph's servers. Returns a list of links.
Allowed only .jpg, .jpeg, .png, .gif and .mp4 files.
:param f: filename or file-like object.
:type f: file, str or list
"""
with FilesOpener(f) as files:
response = requests.post(
'http... | [
"def",
"upload_file",
"(",
"f",
")",
":",
"with",
"FilesOpener",
"(",
"f",
")",
"as",
"files",
":",
"response",
"=",
"requests",
".",
"post",
"(",
"'https://telegra.ph/upload'",
",",
"files",
"=",
"files",
")",
".",
"json",
"(",
")",
"if",
"isinstance",
... | Upload file to Telegra.ph's servers. Returns a list of links.
Allowed only .jpg, .jpeg, .png, .gif and .mp4 files.
:param f: filename or file-like object.
:type f: file, str or list | [
"Upload",
"file",
"to",
"Telegra",
".",
"ph",
"s",
"servers",
".",
"Returns",
"a",
"list",
"of",
"links",
".",
"Allowed",
"only",
".",
"jpg",
".",
"jpeg",
".",
"png",
".",
"gif",
"and",
".",
"mp4",
"files",
"."
] | 6d45cd6bbae4fdbd85b48ce32626f3c66e9e5ddc | https://github.com/python273/telegraph/blob/6d45cd6bbae4fdbd85b48ce32626f3c66e9e5ddc/telegraph/upload.py#L8-L29 | train |
wq/django-natural-keys | natural_keys/models.py | NaturalKeyModelManager.get_by_natural_key | def get_by_natural_key(self, *args):
"""
Return the object corresponding to the provided natural key.
(This is a generic implementation of the standard Django function)
"""
kwargs = self.natural_key_kwargs(*args)
# Since kwargs already has __ lookups in it, we could ju... | python | def get_by_natural_key(self, *args):
"""
Return the object corresponding to the provided natural key.
(This is a generic implementation of the standard Django function)
"""
kwargs = self.natural_key_kwargs(*args)
# Since kwargs already has __ lookups in it, we could ju... | [
"def",
"get_by_natural_key",
"(",
"self",
",",
"*",
"args",
")",
":",
"kwargs",
"=",
"self",
".",
"natural_key_kwargs",
"(",
"*",
"args",
")",
"for",
"name",
",",
"rel_to",
"in",
"self",
".",
"model",
".",
"get_natural_key_info",
"(",
")",
":",
"if",
"... | Return the object corresponding to the provided natural key.
(This is a generic implementation of the standard Django function) | [
"Return",
"the",
"object",
"corresponding",
"to",
"the",
"provided",
"natural",
"key",
"."
] | f6bd6baf848e709ae9920b259a3ad1a6be8af615 | https://github.com/wq/django-natural-keys/blob/f6bd6baf848e709ae9920b259a3ad1a6be8af615/natural_keys/models.py#L38-L70 | train |
wq/django-natural-keys | natural_keys/models.py | NaturalKeyModelManager.create_by_natural_key | def create_by_natural_key(self, *args):
"""
Create a new object from the provided natural key values. If the
natural key contains related objects, recursively get or create them by
their natural keys.
"""
kwargs = self.natural_key_kwargs(*args)
for name, rel_to ... | python | def create_by_natural_key(self, *args):
"""
Create a new object from the provided natural key values. If the
natural key contains related objects, recursively get or create them by
their natural keys.
"""
kwargs = self.natural_key_kwargs(*args)
for name, rel_to ... | [
"def",
"create_by_natural_key",
"(",
"self",
",",
"*",
"args",
")",
":",
"kwargs",
"=",
"self",
".",
"natural_key_kwargs",
"(",
"*",
"args",
")",
"for",
"name",
",",
"rel_to",
"in",
"self",
".",
"model",
".",
"get_natural_key_info",
"(",
")",
":",
"if",
... | Create a new object from the provided natural key values. If the
natural key contains related objects, recursively get or create them by
their natural keys. | [
"Create",
"a",
"new",
"object",
"from",
"the",
"provided",
"natural",
"key",
"values",
".",
"If",
"the",
"natural",
"key",
"contains",
"related",
"objects",
"recursively",
"get",
"or",
"create",
"them",
"by",
"their",
"natural",
"keys",
"."
] | f6bd6baf848e709ae9920b259a3ad1a6be8af615 | https://github.com/wq/django-natural-keys/blob/f6bd6baf848e709ae9920b259a3ad1a6be8af615/natural_keys/models.py#L72-L91 | train |
wq/django-natural-keys | natural_keys/models.py | NaturalKeyModelManager.get_or_create_by_natural_key | def get_or_create_by_natural_key(self, *args):
"""
get_or_create + get_by_natural_key
"""
try:
return self.get_by_natural_key(*args), False
except self.model.DoesNotExist:
return self.create_by_natural_key(*args), True | python | def get_or_create_by_natural_key(self, *args):
"""
get_or_create + get_by_natural_key
"""
try:
return self.get_by_natural_key(*args), False
except self.model.DoesNotExist:
return self.create_by_natural_key(*args), True | [
"def",
"get_or_create_by_natural_key",
"(",
"self",
",",
"*",
"args",
")",
":",
"try",
":",
"return",
"self",
".",
"get_by_natural_key",
"(",
"*",
"args",
")",
",",
"False",
"except",
"self",
".",
"model",
".",
"DoesNotExist",
":",
"return",
"self",
".",
... | get_or_create + get_by_natural_key | [
"get_or_create",
"+",
"get_by_natural_key"
] | f6bd6baf848e709ae9920b259a3ad1a6be8af615 | https://github.com/wq/django-natural-keys/blob/f6bd6baf848e709ae9920b259a3ad1a6be8af615/natural_keys/models.py#L93-L100 | train |
wq/django-natural-keys | natural_keys/models.py | NaturalKeyModelManager.resolve_keys | def resolve_keys(self, keys, auto_create=False):
"""
Resolve the list of given keys into objects, if possible.
Returns a mapping and a success indicator.
"""
resolved = {}
success = True
for key in keys:
if auto_create:
resolved[key] = ... | python | def resolve_keys(self, keys, auto_create=False):
"""
Resolve the list of given keys into objects, if possible.
Returns a mapping and a success indicator.
"""
resolved = {}
success = True
for key in keys:
if auto_create:
resolved[key] = ... | [
"def",
"resolve_keys",
"(",
"self",
",",
"keys",
",",
"auto_create",
"=",
"False",
")",
":",
"resolved",
"=",
"{",
"}",
"success",
"=",
"True",
"for",
"key",
"in",
"keys",
":",
"if",
"auto_create",
":",
"resolved",
"[",
"key",
"]",
"=",
"self",
".",
... | Resolve the list of given keys into objects, if possible.
Returns a mapping and a success indicator. | [
"Resolve",
"the",
"list",
"of",
"given",
"keys",
"into",
"objects",
"if",
"possible",
".",
"Returns",
"a",
"mapping",
"and",
"a",
"success",
"indicator",
"."
] | f6bd6baf848e709ae9920b259a3ad1a6be8af615 | https://github.com/wq/django-natural-keys/blob/f6bd6baf848e709ae9920b259a3ad1a6be8af615/natural_keys/models.py#L117-L133 | train |
wq/django-natural-keys | natural_keys/models.py | NaturalKeyModel.get_natural_key_info | def get_natural_key_info(cls):
"""
Derive natural key from first unique_together definition, noting which
fields are related objects vs. regular fields.
"""
fields = cls.get_natural_key_def()
info = []
for name in fields:
field = cls._meta.get_field(na... | python | def get_natural_key_info(cls):
"""
Derive natural key from first unique_together definition, noting which
fields are related objects vs. regular fields.
"""
fields = cls.get_natural_key_def()
info = []
for name in fields:
field = cls._meta.get_field(na... | [
"def",
"get_natural_key_info",
"(",
"cls",
")",
":",
"fields",
"=",
"cls",
".",
"get_natural_key_def",
"(",
")",
"info",
"=",
"[",
"]",
"for",
"name",
"in",
"fields",
":",
"field",
"=",
"cls",
".",
"_meta",
".",
"get_field",
"(",
"name",
")",
"rel_to",... | Derive natural key from first unique_together definition, noting which
fields are related objects vs. regular fields. | [
"Derive",
"natural",
"key",
"from",
"first",
"unique_together",
"definition",
"noting",
"which",
"fields",
"are",
"related",
"objects",
"vs",
".",
"regular",
"fields",
"."
] | f6bd6baf848e709ae9920b259a3ad1a6be8af615 | https://github.com/wq/django-natural-keys/blob/f6bd6baf848e709ae9920b259a3ad1a6be8af615/natural_keys/models.py#L144-L162 | train |
wq/django-natural-keys | natural_keys/models.py | NaturalKeyModel.get_natural_key_fields | def get_natural_key_fields(cls):
"""
Determine actual natural key field list, incorporating the natural keys
of related objects as needed.
"""
natural_key = []
for name, rel_to in cls.get_natural_key_info():
if not rel_to:
natural_key.append(na... | python | def get_natural_key_fields(cls):
"""
Determine actual natural key field list, incorporating the natural keys
of related objects as needed.
"""
natural_key = []
for name, rel_to in cls.get_natural_key_info():
if not rel_to:
natural_key.append(na... | [
"def",
"get_natural_key_fields",
"(",
"cls",
")",
":",
"natural_key",
"=",
"[",
"]",
"for",
"name",
",",
"rel_to",
"in",
"cls",
".",
"get_natural_key_info",
"(",
")",
":",
"if",
"not",
"rel_to",
":",
"natural_key",
".",
"append",
"(",
"name",
")",
"else"... | Determine actual natural key field list, incorporating the natural keys
of related objects as needed. | [
"Determine",
"actual",
"natural",
"key",
"field",
"list",
"incorporating",
"the",
"natural",
"keys",
"of",
"related",
"objects",
"as",
"needed",
"."
] | f6bd6baf848e709ae9920b259a3ad1a6be8af615 | https://github.com/wq/django-natural-keys/blob/f6bd6baf848e709ae9920b259a3ad1a6be8af615/natural_keys/models.py#L177-L192 | train |
wq/django-natural-keys | natural_keys/models.py | NaturalKeyModel.natural_key | def natural_key(self):
"""
Return the natural key for this object.
(This is a generic implementation of the standard Django function)
"""
# Recursively extract properties from related objects if needed
vals = [reduce(getattr, name.split('__'), self)
for n... | python | def natural_key(self):
"""
Return the natural key for this object.
(This is a generic implementation of the standard Django function)
"""
# Recursively extract properties from related objects if needed
vals = [reduce(getattr, name.split('__'), self)
for n... | [
"def",
"natural_key",
"(",
"self",
")",
":",
"vals",
"=",
"[",
"reduce",
"(",
"getattr",
",",
"name",
".",
"split",
"(",
"'__'",
")",
",",
"self",
")",
"for",
"name",
"in",
"self",
".",
"get_natural_key_fields",
"(",
")",
"]",
"return",
"vals"
] | Return the natural key for this object.
(This is a generic implementation of the standard Django function) | [
"Return",
"the",
"natural",
"key",
"for",
"this",
"object",
"."
] | f6bd6baf848e709ae9920b259a3ad1a6be8af615 | https://github.com/wq/django-natural-keys/blob/f6bd6baf848e709ae9920b259a3ad1a6be8af615/natural_keys/models.py#L194-L203 | train |
SystemRDL/systemrdl-compiler | systemrdl/messages.py | SourceRef.derive_coordinates | def derive_coordinates(self):
"""
Depending on the compilation source, some members of the SourceRef
object may be incomplete.
Calling this function performs the necessary derivations to complete the
object.
"""
if self._coordinates_resolved:
# Coordi... | python | def derive_coordinates(self):
"""
Depending on the compilation source, some members of the SourceRef
object may be incomplete.
Calling this function performs the necessary derivations to complete the
object.
"""
if self._coordinates_resolved:
# Coordi... | [
"def",
"derive_coordinates",
"(",
"self",
")",
":",
"if",
"self",
".",
"_coordinates_resolved",
":",
"return",
"if",
"self",
".",
"seg_map",
"is",
"not",
"None",
":",
"self",
".",
"start",
",",
"self",
".",
"filename",
",",
"include_ref",
"=",
"self",
".... | Depending on the compilation source, some members of the SourceRef
object may be incomplete.
Calling this function performs the necessary derivations to complete the
object. | [
"Depending",
"on",
"the",
"compilation",
"source",
"some",
"members",
"of",
"the",
"SourceRef",
"object",
"may",
"be",
"incomplete",
".",
"Calling",
"this",
"function",
"performs",
"the",
"necessary",
"derivations",
"to",
"complete",
"the",
"object",
"."
] | 6ae64f2bb6ecbbe9db356e20e8ac94e85bdeed3a | https://github.com/SystemRDL/systemrdl-compiler/blob/6ae64f2bb6ecbbe9db356e20e8ac94e85bdeed3a/systemrdl/messages.py#L108-L171 | train |
SystemRDL/systemrdl-compiler | systemrdl/messages.py | MessagePrinter.format_message | def format_message(self, severity, text, src_ref):
"""
Formats the message prior to emitting it.
Parameters
----------
severity: :class:`Severity`
Message severity.
text: str
Body of message
src_ref: :class:`SourceRef`
Referenc... | python | def format_message(self, severity, text, src_ref):
"""
Formats the message prior to emitting it.
Parameters
----------
severity: :class:`Severity`
Message severity.
text: str
Body of message
src_ref: :class:`SourceRef`
Referenc... | [
"def",
"format_message",
"(",
"self",
",",
"severity",
",",
"text",
",",
"src_ref",
")",
":",
"lines",
"=",
"[",
"]",
"if",
"severity",
">=",
"Severity",
".",
"ERROR",
":",
"color",
"=",
"Fore",
".",
"RED",
"elif",
"severity",
">=",
"Severity",
".",
... | Formats the message prior to emitting it.
Parameters
----------
severity: :class:`Severity`
Message severity.
text: str
Body of message
src_ref: :class:`SourceRef`
Reference to source context object
Returns
-------
lis... | [
"Formats",
"the",
"message",
"prior",
"to",
"emitting",
"it",
"."
] | 6ae64f2bb6ecbbe9db356e20e8ac94e85bdeed3a | https://github.com/SystemRDL/systemrdl-compiler/blob/6ae64f2bb6ecbbe9db356e20e8ac94e85bdeed3a/systemrdl/messages.py#L240-L344 | train |
SystemRDL/systemrdl-compiler | systemrdl/messages.py | MessagePrinter.emit_message | def emit_message(self, lines):
"""
Emit message.
Default printer emits messages to stderr
Parameters
----------
lines: list
List of strings containing each line of the message
"""
for line in lines:
print(line, file=sys.stderr) | python | def emit_message(self, lines):
"""
Emit message.
Default printer emits messages to stderr
Parameters
----------
lines: list
List of strings containing each line of the message
"""
for line in lines:
print(line, file=sys.stderr) | [
"def",
"emit_message",
"(",
"self",
",",
"lines",
")",
":",
"for",
"line",
"in",
"lines",
":",
"print",
"(",
"line",
",",
"file",
"=",
"sys",
".",
"stderr",
")"
] | Emit message.
Default printer emits messages to stderr
Parameters
----------
lines: list
List of strings containing each line of the message | [
"Emit",
"message",
".",
"Default",
"printer",
"emits",
"messages",
"to",
"stderr"
] | 6ae64f2bb6ecbbe9db356e20e8ac94e85bdeed3a | https://github.com/SystemRDL/systemrdl-compiler/blob/6ae64f2bb6ecbbe9db356e20e8ac94e85bdeed3a/systemrdl/messages.py#L347-L359 | train |
SystemRDL/systemrdl-compiler | systemrdl/core/parameter.py | Parameter.get_value | def get_value(self):
"""
Evaluate self.expr to get the parameter's value
"""
if (self._value is None) and (self.expr is not None):
self._value = self.expr.get_value()
return self._value | python | def get_value(self):
"""
Evaluate self.expr to get the parameter's value
"""
if (self._value is None) and (self.expr is not None):
self._value = self.expr.get_value()
return self._value | [
"def",
"get_value",
"(",
"self",
")",
":",
"if",
"(",
"self",
".",
"_value",
"is",
"None",
")",
"and",
"(",
"self",
".",
"expr",
"is",
"not",
"None",
")",
":",
"self",
".",
"_value",
"=",
"self",
".",
"expr",
".",
"get_value",
"(",
")",
"return",... | Evaluate self.expr to get the parameter's value | [
"Evaluate",
"self",
".",
"expr",
"to",
"get",
"the",
"parameter",
"s",
"value"
] | 6ae64f2bb6ecbbe9db356e20e8ac94e85bdeed3a | https://github.com/SystemRDL/systemrdl-compiler/blob/6ae64f2bb6ecbbe9db356e20e8ac94e85bdeed3a/systemrdl/core/parameter.py#L17-L24 | train |
SystemRDL/systemrdl-compiler | systemrdl/core/expressions.py | is_castable | def is_castable(src, dst):
"""
Check if src type can be cast to dst type
"""
if ((src in [int, bool]) or rdltypes.is_user_enum(src)) and (dst in [int, bool]):
# Pure numeric or enum can be cast to a numeric
return True
elif (src == rdltypes.ArrayPlaceholder) and (dst == rdltypes.Arra... | python | def is_castable(src, dst):
"""
Check if src type can be cast to dst type
"""
if ((src in [int, bool]) or rdltypes.is_user_enum(src)) and (dst in [int, bool]):
# Pure numeric or enum can be cast to a numeric
return True
elif (src == rdltypes.ArrayPlaceholder) and (dst == rdltypes.Arra... | [
"def",
"is_castable",
"(",
"src",
",",
"dst",
")",
":",
"if",
"(",
"(",
"src",
"in",
"[",
"int",
",",
"bool",
"]",
")",
"or",
"rdltypes",
".",
"is_user_enum",
"(",
"src",
")",
")",
"and",
"(",
"dst",
"in",
"[",
"int",
",",
"bool",
"]",
")",
"... | Check if src type can be cast to dst type | [
"Check",
"if",
"src",
"type",
"can",
"be",
"cast",
"to",
"dst",
"type"
] | 6ae64f2bb6ecbbe9db356e20e8ac94e85bdeed3a | https://github.com/SystemRDL/systemrdl-compiler/blob/6ae64f2bb6ecbbe9db356e20e8ac94e85bdeed3a/systemrdl/core/expressions.py#L1193-L1217 | train |
SystemRDL/systemrdl-compiler | systemrdl/core/expressions.py | InstRef.predict_type | def predict_type(self):
"""
Traverse the ref_elements path and determine the component type being
referenced.
Also do some checks on the array indexes
"""
current_comp = self.ref_root
for name, array_suffixes, name_src_ref in self.ref_elements:
# find... | python | def predict_type(self):
"""
Traverse the ref_elements path and determine the component type being
referenced.
Also do some checks on the array indexes
"""
current_comp = self.ref_root
for name, array_suffixes, name_src_ref in self.ref_elements:
# find... | [
"def",
"predict_type",
"(",
"self",
")",
":",
"current_comp",
"=",
"self",
".",
"ref_root",
"for",
"name",
",",
"array_suffixes",
",",
"name_src_ref",
"in",
"self",
".",
"ref_elements",
":",
"current_comp",
"=",
"current_comp",
".",
"get_child_by_name",
"(",
"... | Traverse the ref_elements path and determine the component type being
referenced.
Also do some checks on the array indexes | [
"Traverse",
"the",
"ref_elements",
"path",
"and",
"determine",
"the",
"component",
"type",
"being",
"referenced",
".",
"Also",
"do",
"some",
"checks",
"on",
"the",
"array",
"indexes"
] | 6ae64f2bb6ecbbe9db356e20e8ac94e85bdeed3a | https://github.com/SystemRDL/systemrdl-compiler/blob/6ae64f2bb6ecbbe9db356e20e8ac94e85bdeed3a/systemrdl/core/expressions.py#L1063-L1101 | train |
SystemRDL/systemrdl-compiler | systemrdl/core/expressions.py | InstRef.get_value | def get_value(self, eval_width=None):
"""
Build a resolved ComponentRef container that describes the relative path
"""
resolved_ref_elements = []
for name, array_suffixes, name_src_ref in self.ref_elements:
idx_list = [ suffix.get_value() for suffix in array_suffixe... | python | def get_value(self, eval_width=None):
"""
Build a resolved ComponentRef container that describes the relative path
"""
resolved_ref_elements = []
for name, array_suffixes, name_src_ref in self.ref_elements:
idx_list = [ suffix.get_value() for suffix in array_suffixe... | [
"def",
"get_value",
"(",
"self",
",",
"eval_width",
"=",
"None",
")",
":",
"resolved_ref_elements",
"=",
"[",
"]",
"for",
"name",
",",
"array_suffixes",
",",
"name_src_ref",
"in",
"self",
".",
"ref_elements",
":",
"idx_list",
"=",
"[",
"suffix",
".",
"get_... | Build a resolved ComponentRef container that describes the relative path | [
"Build",
"a",
"resolved",
"ComponentRef",
"container",
"that",
"describes",
"the",
"relative",
"path"
] | 6ae64f2bb6ecbbe9db356e20e8ac94e85bdeed3a | https://github.com/SystemRDL/systemrdl-compiler/blob/6ae64f2bb6ecbbe9db356e20e8ac94e85bdeed3a/systemrdl/core/expressions.py#L1103-L1117 | train |
SystemRDL/systemrdl-compiler | systemrdl/core/expressions.py | PropRef.predict_type | def predict_type(self):
"""
Predict the type of the inst_ref, and make sure the property being
referenced is allowed
"""
inst_type = self.inst_ref.predict_type()
if self.prop_ref_type.allowed_inst_type != inst_type:
self.msg.fatal(
"'%s' is no... | python | def predict_type(self):
"""
Predict the type of the inst_ref, and make sure the property being
referenced is allowed
"""
inst_type = self.inst_ref.predict_type()
if self.prop_ref_type.allowed_inst_type != inst_type:
self.msg.fatal(
"'%s' is no... | [
"def",
"predict_type",
"(",
"self",
")",
":",
"inst_type",
"=",
"self",
".",
"inst_ref",
".",
"predict_type",
"(",
")",
"if",
"self",
".",
"prop_ref_type",
".",
"allowed_inst_type",
"!=",
"inst_type",
":",
"self",
".",
"msg",
".",
"fatal",
"(",
"\"'%s' is ... | Predict the type of the inst_ref, and make sure the property being
referenced is allowed | [
"Predict",
"the",
"type",
"of",
"the",
"inst_ref",
"and",
"make",
"sure",
"the",
"property",
"being",
"referenced",
"is",
"allowed"
] | 6ae64f2bb6ecbbe9db356e20e8ac94e85bdeed3a | https://github.com/SystemRDL/systemrdl-compiler/blob/6ae64f2bb6ecbbe9db356e20e8ac94e85bdeed3a/systemrdl/core/expressions.py#L1129-L1142 | train |
SystemRDL/systemrdl-compiler | systemrdl/node.py | get_group_node_size | def get_group_node_size(node):
"""
Shared getter for AddrmapNode and RegfileNode's "size" property
"""
# After structural placement, children are sorted
if( not node.inst.children
or (not isinstance(node.inst.children[-1], comp.AddressableComponent))
):
# No addressable child exi... | python | def get_group_node_size(node):
"""
Shared getter for AddrmapNode and RegfileNode's "size" property
"""
# After structural placement, children are sorted
if( not node.inst.children
or (not isinstance(node.inst.children[-1], comp.AddressableComponent))
):
# No addressable child exi... | [
"def",
"get_group_node_size",
"(",
"node",
")",
":",
"if",
"(",
"not",
"node",
".",
"inst",
".",
"children",
"or",
"(",
"not",
"isinstance",
"(",
"node",
".",
"inst",
".",
"children",
"[",
"-",
"1",
"]",
",",
"comp",
".",
"AddressableComponent",
")",
... | Shared getter for AddrmapNode and RegfileNode's "size" property | [
"Shared",
"getter",
"for",
"AddrmapNode",
"and",
"RegfileNode",
"s",
"size",
"property"
] | 6ae64f2bb6ecbbe9db356e20e8ac94e85bdeed3a | https://github.com/SystemRDL/systemrdl-compiler/blob/6ae64f2bb6ecbbe9db356e20e8ac94e85bdeed3a/systemrdl/node.py#L810-L826 | train |
SystemRDL/systemrdl-compiler | systemrdl/node.py | Node.add_derived_property | def add_derived_property(cls, getter_function, name=None):
"""
Register a user-defined derived property
Parameters
----------
getter_function : function
Function that fetches the result of the user-defined derived property
name : str
Derived prope... | python | def add_derived_property(cls, getter_function, name=None):
"""
Register a user-defined derived property
Parameters
----------
getter_function : function
Function that fetches the result of the user-defined derived property
name : str
Derived prope... | [
"def",
"add_derived_property",
"(",
"cls",
",",
"getter_function",
",",
"name",
"=",
"None",
")",
":",
"if",
"name",
"is",
"None",
":",
"name",
"=",
"getter_function",
".",
"__name__",
"mp",
"=",
"property",
"(",
"fget",
"=",
"getter_function",
")",
"setat... | Register a user-defined derived property
Parameters
----------
getter_function : function
Function that fetches the result of the user-defined derived property
name : str
Derived property name
If unassigned, will default to the function's name | [
"Register",
"a",
"user",
"-",
"defined",
"derived",
"property"
] | 6ae64f2bb6ecbbe9db356e20e8ac94e85bdeed3a | https://github.com/SystemRDL/systemrdl-compiler/blob/6ae64f2bb6ecbbe9db356e20e8ac94e85bdeed3a/systemrdl/node.py#L55-L71 | train |
SystemRDL/systemrdl-compiler | systemrdl/node.py | Node.children | def children(self, unroll=False, skip_not_present=True):
"""
Returns an iterator that provides nodes for all immediate children of
this component.
Parameters
----------
unroll : bool
If True, any children that are arrays are unrolled.
skip_not_presen... | python | def children(self, unroll=False, skip_not_present=True):
"""
Returns an iterator that provides nodes for all immediate children of
this component.
Parameters
----------
unroll : bool
If True, any children that are arrays are unrolled.
skip_not_presen... | [
"def",
"children",
"(",
"self",
",",
"unroll",
"=",
"False",
",",
"skip_not_present",
"=",
"True",
")",
":",
"for",
"child_inst",
"in",
"self",
".",
"inst",
".",
"children",
":",
"if",
"skip_not_present",
":",
"if",
"not",
"child_inst",
".",
"properties",
... | Returns an iterator that provides nodes for all immediate children of
this component.
Parameters
----------
unroll : bool
If True, any children that are arrays are unrolled.
skip_not_present : bool
If True, skips children whose 'ispresent' property is se... | [
"Returns",
"an",
"iterator",
"that",
"provides",
"nodes",
"for",
"all",
"immediate",
"children",
"of",
"this",
"component",
"."
] | 6ae64f2bb6ecbbe9db356e20e8ac94e85bdeed3a | https://github.com/SystemRDL/systemrdl-compiler/blob/6ae64f2bb6ecbbe9db356e20e8ac94e85bdeed3a/systemrdl/node.py#L74-L107 | train |
SystemRDL/systemrdl-compiler | systemrdl/node.py | Node.descendants | def descendants(self, unroll=False, skip_not_present=True, in_post_order=False):
"""
Returns an iterator that provides nodes for all descendants of this
component.
Parameters
----------
unroll : bool
If True, any children that are arrays are unrolled.
... | python | def descendants(self, unroll=False, skip_not_present=True, in_post_order=False):
"""
Returns an iterator that provides nodes for all descendants of this
component.
Parameters
----------
unroll : bool
If True, any children that are arrays are unrolled.
... | [
"def",
"descendants",
"(",
"self",
",",
"unroll",
"=",
"False",
",",
"skip_not_present",
"=",
"True",
",",
"in_post_order",
"=",
"False",
")",
":",
"for",
"child",
"in",
"self",
".",
"children",
"(",
"unroll",
",",
"skip_not_present",
")",
":",
"if",
"in... | Returns an iterator that provides nodes for all descendants of this
component.
Parameters
----------
unroll : bool
If True, any children that are arrays are unrolled.
skip_not_present : bool
If True, skips children whose 'ispresent' property is set to Fa... | [
"Returns",
"an",
"iterator",
"that",
"provides",
"nodes",
"for",
"all",
"descendants",
"of",
"this",
"component",
"."
] | 6ae64f2bb6ecbbe9db356e20e8ac94e85bdeed3a | https://github.com/SystemRDL/systemrdl-compiler/blob/6ae64f2bb6ecbbe9db356e20e8ac94e85bdeed3a/systemrdl/node.py#L110-L140 | train |
SystemRDL/systemrdl-compiler | systemrdl/node.py | Node.signals | def signals(self, skip_not_present=True):
"""
Returns an iterator that provides nodes for all immediate signals of
this component.
Parameters
----------
skip_not_present : bool
If True, skips children whose 'ispresent' property is set to False
Yields... | python | def signals(self, skip_not_present=True):
"""
Returns an iterator that provides nodes for all immediate signals of
this component.
Parameters
----------
skip_not_present : bool
If True, skips children whose 'ispresent' property is set to False
Yields... | [
"def",
"signals",
"(",
"self",
",",
"skip_not_present",
"=",
"True",
")",
":",
"for",
"child",
"in",
"self",
".",
"children",
"(",
"skip_not_present",
"=",
"skip_not_present",
")",
":",
"if",
"isinstance",
"(",
"child",
",",
"SignalNode",
")",
":",
"yield"... | Returns an iterator that provides nodes for all immediate signals of
this component.
Parameters
----------
skip_not_present : bool
If True, skips children whose 'ispresent' property is set to False
Yields
------
:class:`~SignalNode`
All s... | [
"Returns",
"an",
"iterator",
"that",
"provides",
"nodes",
"for",
"all",
"immediate",
"signals",
"of",
"this",
"component",
"."
] | 6ae64f2bb6ecbbe9db356e20e8ac94e85bdeed3a | https://github.com/SystemRDL/systemrdl-compiler/blob/6ae64f2bb6ecbbe9db356e20e8ac94e85bdeed3a/systemrdl/node.py#L143-L160 | train |
SystemRDL/systemrdl-compiler | systemrdl/node.py | Node.fields | def fields(self, skip_not_present=True):
"""
Returns an iterator that provides nodes for all immediate fields of
this component.
Parameters
----------
skip_not_present : bool
If True, skips children whose 'ispresent' property is set to False
Yields
... | python | def fields(self, skip_not_present=True):
"""
Returns an iterator that provides nodes for all immediate fields of
this component.
Parameters
----------
skip_not_present : bool
If True, skips children whose 'ispresent' property is set to False
Yields
... | [
"def",
"fields",
"(",
"self",
",",
"skip_not_present",
"=",
"True",
")",
":",
"for",
"child",
"in",
"self",
".",
"children",
"(",
"skip_not_present",
"=",
"skip_not_present",
")",
":",
"if",
"isinstance",
"(",
"child",
",",
"FieldNode",
")",
":",
"yield",
... | Returns an iterator that provides nodes for all immediate fields of
this component.
Parameters
----------
skip_not_present : bool
If True, skips children whose 'ispresent' property is set to False
Yields
------
:class:`~FieldNode`
All fie... | [
"Returns",
"an",
"iterator",
"that",
"provides",
"nodes",
"for",
"all",
"immediate",
"fields",
"of",
"this",
"component",
"."
] | 6ae64f2bb6ecbbe9db356e20e8ac94e85bdeed3a | https://github.com/SystemRDL/systemrdl-compiler/blob/6ae64f2bb6ecbbe9db356e20e8ac94e85bdeed3a/systemrdl/node.py#L163-L180 | train |
SystemRDL/systemrdl-compiler | systemrdl/node.py | Node.registers | def registers(self, unroll=False, skip_not_present=True):
"""
Returns an iterator that provides nodes for all immediate registers of
this component.
Parameters
----------
unroll : bool
If True, any children that are arrays are unrolled.
skip_not_pres... | python | def registers(self, unroll=False, skip_not_present=True):
"""
Returns an iterator that provides nodes for all immediate registers of
this component.
Parameters
----------
unroll : bool
If True, any children that are arrays are unrolled.
skip_not_pres... | [
"def",
"registers",
"(",
"self",
",",
"unroll",
"=",
"False",
",",
"skip_not_present",
"=",
"True",
")",
":",
"for",
"child",
"in",
"self",
".",
"children",
"(",
"unroll",
",",
"skip_not_present",
")",
":",
"if",
"isinstance",
"(",
"child",
",",
"RegNode... | Returns an iterator that provides nodes for all immediate registers of
this component.
Parameters
----------
unroll : bool
If True, any children that are arrays are unrolled.
skip_not_present : bool
If True, skips children whose 'ispresent' property is s... | [
"Returns",
"an",
"iterator",
"that",
"provides",
"nodes",
"for",
"all",
"immediate",
"registers",
"of",
"this",
"component",
"."
] | 6ae64f2bb6ecbbe9db356e20e8ac94e85bdeed3a | https://github.com/SystemRDL/systemrdl-compiler/blob/6ae64f2bb6ecbbe9db356e20e8ac94e85bdeed3a/systemrdl/node.py#L183-L203 | train |
SystemRDL/systemrdl-compiler | systemrdl/node.py | Node.find_by_path | def find_by_path(self, path):
"""
Finds the descendant node that is located at the relative path
Returns ``None`` if not found
Raises exception if path is malformed, or array index is out of range
Parameters
----------
path: str
Path to target relativ... | python | def find_by_path(self, path):
"""
Finds the descendant node that is located at the relative path
Returns ``None`` if not found
Raises exception if path is malformed, or array index is out of range
Parameters
----------
path: str
Path to target relativ... | [
"def",
"find_by_path",
"(",
"self",
",",
"path",
")",
":",
"pathparts",
"=",
"path",
".",
"split",
"(",
"'.'",
")",
"current_node",
"=",
"self",
"for",
"pathpart",
"in",
"pathparts",
":",
"m",
"=",
"re",
".",
"fullmatch",
"(",
"r'^(\\w+)((?:\\[(?:\\d+|0[xX... | Finds the descendant node that is located at the relative path
Returns ``None`` if not found
Raises exception if path is malformed, or array index is out of range
Parameters
----------
path: str
Path to target relative to current node
Returns
-------... | [
"Finds",
"the",
"descendant",
"node",
"that",
"is",
"located",
"at",
"the",
"relative",
"path",
"Returns",
"None",
"if",
"not",
"found",
"Raises",
"exception",
"if",
"path",
"is",
"malformed",
"or",
"array",
"index",
"is",
"out",
"of",
"range"
] | 6ae64f2bb6ecbbe9db356e20e8ac94e85bdeed3a | https://github.com/SystemRDL/systemrdl-compiler/blob/6ae64f2bb6ecbbe9db356e20e8ac94e85bdeed3a/systemrdl/node.py#L228-L278 | train |
SystemRDL/systemrdl-compiler | systemrdl/node.py | Node.get_property | def get_property(self, prop_name, **kwargs):
"""
Gets the SystemRDL component property
If a property was not explicitly set in the RDL source, its default
value is derived. In some cases, a default value is implied according to
other property values.
Properties values t... | python | def get_property(self, prop_name, **kwargs):
"""
Gets the SystemRDL component property
If a property was not explicitly set in the RDL source, its default
value is derived. In some cases, a default value is implied according to
other property values.
Properties values t... | [
"def",
"get_property",
"(",
"self",
",",
"prop_name",
",",
"**",
"kwargs",
")",
":",
"ovr_default",
"=",
"False",
"default",
"=",
"None",
"if",
"'default'",
"in",
"kwargs",
":",
"ovr_default",
"=",
"True",
"default",
"=",
"kwargs",
".",
"pop",
"(",
"'def... | Gets the SystemRDL component property
If a property was not explicitly set in the RDL source, its default
value is derived. In some cases, a default value is implied according to
other property values.
Properties values that are a reference to a component instance are
converted... | [
"Gets",
"the",
"SystemRDL",
"component",
"property"
] | 6ae64f2bb6ecbbe9db356e20e8ac94e85bdeed3a | https://github.com/SystemRDL/systemrdl-compiler/blob/6ae64f2bb6ecbbe9db356e20e8ac94e85bdeed3a/systemrdl/node.py#L281-L343 | train |
SystemRDL/systemrdl-compiler | systemrdl/node.py | Node.list_properties | def list_properties(self, list_all=False):
"""
Lists properties associated with this node.
By default, only lists properties that were explicitly set. If ``list_all`` is
set to ``True`` then lists all valid properties of this component type
Parameters
----------
... | python | def list_properties(self, list_all=False):
"""
Lists properties associated with this node.
By default, only lists properties that were explicitly set. If ``list_all`` is
set to ``True`` then lists all valid properties of this component type
Parameters
----------
... | [
"def",
"list_properties",
"(",
"self",
",",
"list_all",
"=",
"False",
")",
":",
"if",
"list_all",
":",
"props",
"=",
"[",
"]",
"for",
"k",
",",
"v",
"in",
"self",
".",
"env",
".",
"property_rules",
".",
"rdl_properties",
".",
"items",
"(",
")",
":",
... | Lists properties associated with this node.
By default, only lists properties that were explicitly set. If ``list_all`` is
set to ``True`` then lists all valid properties of this component type
Parameters
----------
list_all: bool
If true, lists all valid properties ... | [
"Lists",
"properties",
"associated",
"with",
"this",
"node",
".",
"By",
"default",
"only",
"lists",
"properties",
"that",
"were",
"explicitly",
"set",
".",
"If",
"list_all",
"is",
"set",
"to",
"True",
"then",
"lists",
"all",
"valid",
"properties",
"of",
"thi... | 6ae64f2bb6ecbbe9db356e20e8ac94e85bdeed3a | https://github.com/SystemRDL/systemrdl-compiler/blob/6ae64f2bb6ecbbe9db356e20e8ac94e85bdeed3a/systemrdl/node.py#L346-L368 | train |
SystemRDL/systemrdl-compiler | systemrdl/node.py | Node.get_path | def get_path(self, hier_separator=".", array_suffix="[{index:d}]", empty_array_suffix="[]"):
"""
Generate an absolute path string to this node
Parameters
----------
hier_separator: str
Override the hierarchy separator
array_suffix: str
Override ho... | python | def get_path(self, hier_separator=".", array_suffix="[{index:d}]", empty_array_suffix="[]"):
"""
Generate an absolute path string to this node
Parameters
----------
hier_separator: str
Override the hierarchy separator
array_suffix: str
Override ho... | [
"def",
"get_path",
"(",
"self",
",",
"hier_separator",
"=",
"\".\"",
",",
"array_suffix",
"=",
"\"[{index:d}]\"",
",",
"empty_array_suffix",
"=",
"\"[]\"",
")",
":",
"if",
"self",
".",
"parent",
"and",
"not",
"isinstance",
"(",
"self",
".",
"parent",
",",
... | Generate an absolute path string to this node
Parameters
----------
hier_separator: str
Override the hierarchy separator
array_suffix: str
Override how array suffixes are represented when the index is known
empty_array_suffix: str
Override how... | [
"Generate",
"an",
"absolute",
"path",
"string",
"to",
"this",
"node"
] | 6ae64f2bb6ecbbe9db356e20e8ac94e85bdeed3a | https://github.com/SystemRDL/systemrdl-compiler/blob/6ae64f2bb6ecbbe9db356e20e8ac94e85bdeed3a/systemrdl/node.py#L387-L407 | train |
SystemRDL/systemrdl-compiler | systemrdl/node.py | Node.get_html_desc | def get_html_desc(self, markdown_inst=None):
"""
Translates the node's 'desc' property into HTML.
Any RDLFormatCode tags used in the description are converted to HTML.
The text is also fed through a Markdown processor.
The additional Markdown processing allows designers the cho... | python | def get_html_desc(self, markdown_inst=None):
"""
Translates the node's 'desc' property into HTML.
Any RDLFormatCode tags used in the description are converted to HTML.
The text is also fed through a Markdown processor.
The additional Markdown processing allows designers the cho... | [
"def",
"get_html_desc",
"(",
"self",
",",
"markdown_inst",
"=",
"None",
")",
":",
"desc_str",
"=",
"self",
".",
"get_property",
"(",
"\"desc\"",
")",
"if",
"desc_str",
"is",
"None",
":",
"return",
"None",
"return",
"rdlformatcode",
".",
"rdlfc_to_html",
"(",... | Translates the node's 'desc' property into HTML.
Any RDLFormatCode tags used in the description are converted to HTML.
The text is also fed through a Markdown processor.
The additional Markdown processing allows designers the choice to use a
more modern lightweight markup language as a... | [
"Translates",
"the",
"node",
"s",
"desc",
"property",
"into",
"HTML",
"."
] | 6ae64f2bb6ecbbe9db356e20e8ac94e85bdeed3a | https://github.com/SystemRDL/systemrdl-compiler/blob/6ae64f2bb6ecbbe9db356e20e8ac94e85bdeed3a/systemrdl/node.py#L409-L437 | train |
SystemRDL/systemrdl-compiler | systemrdl/node.py | AddressableNode.address_offset | def address_offset(self):
"""
Byte address offset of this node relative to it's parent
If this node is an array, it's index must be known
Raises
------
ValueError
If this property is referenced on a node whose array index is not
fully defined
... | python | def address_offset(self):
"""
Byte address offset of this node relative to it's parent
If this node is an array, it's index must be known
Raises
------
ValueError
If this property is referenced on a node whose array index is not
fully defined
... | [
"def",
"address_offset",
"(",
"self",
")",
":",
"if",
"self",
".",
"inst",
".",
"is_array",
":",
"if",
"self",
".",
"current_idx",
"is",
"None",
":",
"raise",
"ValueError",
"(",
"\"Index of array element must be known to derive address\"",
")",
"idx",
"=",
"0",
... | Byte address offset of this node relative to it's parent
If this node is an array, it's index must be known
Raises
------
ValueError
If this property is referenced on a node whose array index is not
fully defined | [
"Byte",
"address",
"offset",
"of",
"this",
"node",
"relative",
"to",
"it",
"s",
"parent"
] | 6ae64f2bb6ecbbe9db356e20e8ac94e85bdeed3a | https://github.com/SystemRDL/systemrdl-compiler/blob/6ae64f2bb6ecbbe9db356e20e8ac94e85bdeed3a/systemrdl/node.py#L496-L531 | train |
SystemRDL/systemrdl-compiler | systemrdl/node.py | AddressableNode.absolute_address | def absolute_address(self):
"""
Get the absolute byte address of this node.
Indexes of all arrays in the node's lineage must be known
Raises
------
ValueError
If this property is referenced on a node whose array lineage is not
fully defined
... | python | def absolute_address(self):
"""
Get the absolute byte address of this node.
Indexes of all arrays in the node's lineage must be known
Raises
------
ValueError
If this property is referenced on a node whose array lineage is not
fully defined
... | [
"def",
"absolute_address",
"(",
"self",
")",
":",
"if",
"self",
".",
"parent",
"and",
"not",
"isinstance",
"(",
"self",
".",
"parent",
",",
"RootNode",
")",
":",
"return",
"self",
".",
"parent",
".",
"absolute_address",
"+",
"self",
".",
"address_offset",
... | Get the absolute byte address of this node.
Indexes of all arrays in the node's lineage must be known
Raises
------
ValueError
If this property is referenced on a node whose array lineage is not
fully defined | [
"Get",
"the",
"absolute",
"byte",
"address",
"of",
"this",
"node",
"."
] | 6ae64f2bb6ecbbe9db356e20e8ac94e85bdeed3a | https://github.com/SystemRDL/systemrdl-compiler/blob/6ae64f2bb6ecbbe9db356e20e8ac94e85bdeed3a/systemrdl/node.py#L535-L551 | train |
SystemRDL/systemrdl-compiler | systemrdl/node.py | RootNode.top | def top(self):
"""
Returns the top-level addrmap node
"""
for child in self.children(skip_not_present=False):
if not isinstance(child, AddrmapNode):
continue
return child
raise RuntimeError | python | def top(self):
"""
Returns the top-level addrmap node
"""
for child in self.children(skip_not_present=False):
if not isinstance(child, AddrmapNode):
continue
return child
raise RuntimeError | [
"def",
"top",
"(",
"self",
")",
":",
"for",
"child",
"in",
"self",
".",
"children",
"(",
"skip_not_present",
"=",
"False",
")",
":",
"if",
"not",
"isinstance",
"(",
"child",
",",
"AddrmapNode",
")",
":",
"continue",
"return",
"child",
"raise",
"RuntimeEr... | Returns the top-level addrmap node | [
"Returns",
"the",
"top",
"-",
"level",
"addrmap",
"node"
] | 6ae64f2bb6ecbbe9db356e20e8ac94e85bdeed3a | https://github.com/SystemRDL/systemrdl-compiler/blob/6ae64f2bb6ecbbe9db356e20e8ac94e85bdeed3a/systemrdl/node.py#L653-L661 | train |
SystemRDL/systemrdl-compiler | systemrdl/node.py | FieldNode.is_sw_writable | def is_sw_writable(self):
"""
Field is writable by software
"""
sw = self.get_property('sw')
return sw in (rdltypes.AccessType.rw, rdltypes.AccessType.rw1,
rdltypes.AccessType.w, rdltypes.AccessType.w1) | python | def is_sw_writable(self):
"""
Field is writable by software
"""
sw = self.get_property('sw')
return sw in (rdltypes.AccessType.rw, rdltypes.AccessType.rw1,
rdltypes.AccessType.w, rdltypes.AccessType.w1) | [
"def",
"is_sw_writable",
"(",
"self",
")",
":",
"sw",
"=",
"self",
".",
"get_property",
"(",
"'sw'",
")",
"return",
"sw",
"in",
"(",
"rdltypes",
".",
"AccessType",
".",
"rw",
",",
"rdltypes",
".",
"AccessType",
".",
"rw1",
",",
"rdltypes",
".",
"Access... | Field is writable by software | [
"Field",
"is",
"writable",
"by",
"software"
] | 6ae64f2bb6ecbbe9db356e20e8ac94e85bdeed3a | https://github.com/SystemRDL/systemrdl-compiler/blob/6ae64f2bb6ecbbe9db356e20e8ac94e85bdeed3a/systemrdl/node.py#L696-L703 | train |
SystemRDL/systemrdl-compiler | systemrdl/node.py | FieldNode.is_sw_readable | def is_sw_readable(self):
"""
Field is readable by software
"""
sw = self.get_property('sw')
return sw in (rdltypes.AccessType.rw, rdltypes.AccessType.rw1,
rdltypes.AccessType.r) | python | def is_sw_readable(self):
"""
Field is readable by software
"""
sw = self.get_property('sw')
return sw in (rdltypes.AccessType.rw, rdltypes.AccessType.rw1,
rdltypes.AccessType.r) | [
"def",
"is_sw_readable",
"(",
"self",
")",
":",
"sw",
"=",
"self",
".",
"get_property",
"(",
"'sw'",
")",
"return",
"sw",
"in",
"(",
"rdltypes",
".",
"AccessType",
".",
"rw",
",",
"rdltypes",
".",
"AccessType",
".",
"rw1",
",",
"rdltypes",
".",
"Access... | Field is readable by software | [
"Field",
"is",
"readable",
"by",
"software"
] | 6ae64f2bb6ecbbe9db356e20e8ac94e85bdeed3a | https://github.com/SystemRDL/systemrdl-compiler/blob/6ae64f2bb6ecbbe9db356e20e8ac94e85bdeed3a/systemrdl/node.py#L706-L713 | train |
SystemRDL/systemrdl-compiler | systemrdl/node.py | FieldNode.implements_storage | def implements_storage(self):
"""
True if combination of field access properties imply that the field
implements a storage element.
"""
# 9.4.1, Table 12
sw = self.get_property('sw')
hw = self.get_property('hw')
if sw in (rdltypes.AccessType.rw, rdltypes.... | python | def implements_storage(self):
"""
True if combination of field access properties imply that the field
implements a storage element.
"""
# 9.4.1, Table 12
sw = self.get_property('sw')
hw = self.get_property('hw')
if sw in (rdltypes.AccessType.rw, rdltypes.... | [
"def",
"implements_storage",
"(",
"self",
")",
":",
"sw",
"=",
"self",
".",
"get_property",
"(",
"'sw'",
")",
"hw",
"=",
"self",
".",
"get_property",
"(",
"'hw'",
")",
"if",
"sw",
"in",
"(",
"rdltypes",
".",
"AccessType",
".",
"rw",
",",
"rdltypes",
... | True if combination of field access properties imply that the field
implements a storage element. | [
"True",
"if",
"combination",
"of",
"field",
"access",
"properties",
"imply",
"that",
"the",
"field",
"implements",
"a",
"storage",
"element",
"."
] | 6ae64f2bb6ecbbe9db356e20e8ac94e85bdeed3a | https://github.com/SystemRDL/systemrdl-compiler/blob/6ae64f2bb6ecbbe9db356e20e8ac94e85bdeed3a/systemrdl/node.py#L716-L747 | train |
SystemRDL/systemrdl-compiler | systemrdl/core/ComponentVisitor.py | ComponentVisitor.visitComponent_def | def visitComponent_def(self, ctx:SystemRDLParser.Component_defContext):
"""
Create, and possibly instantiate a component
"""
# Get definition. Returns Component
if ctx.component_anon_def() is not None:
comp_def = self.visit(ctx.component_anon_def())
elif ctx.... | python | def visitComponent_def(self, ctx:SystemRDLParser.Component_defContext):
"""
Create, and possibly instantiate a component
"""
# Get definition. Returns Component
if ctx.component_anon_def() is not None:
comp_def = self.visit(ctx.component_anon_def())
elif ctx.... | [
"def",
"visitComponent_def",
"(",
"self",
",",
"ctx",
":",
"SystemRDLParser",
".",
"Component_defContext",
")",
":",
"if",
"ctx",
".",
"component_anon_def",
"(",
")",
"is",
"not",
"None",
":",
"comp_def",
"=",
"self",
".",
"visit",
"(",
"ctx",
".",
"compon... | Create, and possibly instantiate a component | [
"Create",
"and",
"possibly",
"instantiate",
"a",
"component"
] | 6ae64f2bb6ecbbe9db356e20e8ac94e85bdeed3a | https://github.com/SystemRDL/systemrdl-compiler/blob/6ae64f2bb6ecbbe9db356e20e8ac94e85bdeed3a/systemrdl/core/ComponentVisitor.py#L76-L108 | train |
SystemRDL/systemrdl-compiler | systemrdl/core/ComponentVisitor.py | ComponentVisitor.define_component | def define_component(self, body, type_token, def_name, param_defs):
"""
Given component definition, recurse to another ComponentVisitor
to define a new component
"""
for subclass in ComponentVisitor.__subclasses__():
if subclass.comp_type == self._CompType_Map[type_to... | python | def define_component(self, body, type_token, def_name, param_defs):
"""
Given component definition, recurse to another ComponentVisitor
to define a new component
"""
for subclass in ComponentVisitor.__subclasses__():
if subclass.comp_type == self._CompType_Map[type_to... | [
"def",
"define_component",
"(",
"self",
",",
"body",
",",
"type_token",
",",
"def_name",
",",
"param_defs",
")",
":",
"for",
"subclass",
"in",
"ComponentVisitor",
".",
"__subclasses__",
"(",
")",
":",
"if",
"subclass",
".",
"comp_type",
"==",
"self",
".",
... | Given component definition, recurse to another ComponentVisitor
to define a new component | [
"Given",
"component",
"definition",
"recurse",
"to",
"another",
"ComponentVisitor",
"to",
"define",
"a",
"new",
"component"
] | 6ae64f2bb6ecbbe9db356e20e8ac94e85bdeed3a | https://github.com/SystemRDL/systemrdl-compiler/blob/6ae64f2bb6ecbbe9db356e20e8ac94e85bdeed3a/systemrdl/core/ComponentVisitor.py#L153-L162 | train |
SystemRDL/systemrdl-compiler | systemrdl/core/ComponentVisitor.py | ComponentVisitor.get_instance_assignment | def get_instance_assignment(self, ctx):
"""
Gets the integer expression in any of the four instance assignment
operators ('=' '@' '+=' '%=')
"""
if ctx is None:
return None
visitor = ExprVisitor(self.compiler)
expr = visitor.visit(ctx.expr())
... | python | def get_instance_assignment(self, ctx):
"""
Gets the integer expression in any of the four instance assignment
operators ('=' '@' '+=' '%=')
"""
if ctx is None:
return None
visitor = ExprVisitor(self.compiler)
expr = visitor.visit(ctx.expr())
... | [
"def",
"get_instance_assignment",
"(",
"self",
",",
"ctx",
")",
":",
"if",
"ctx",
"is",
"None",
":",
"return",
"None",
"visitor",
"=",
"ExprVisitor",
"(",
"self",
".",
"compiler",
")",
"expr",
"=",
"visitor",
".",
"visit",
"(",
"ctx",
".",
"expr",
"(",... | Gets the integer expression in any of the four instance assignment
operators ('=' '@' '+=' '%=') | [
"Gets",
"the",
"integer",
"expression",
"in",
"any",
"of",
"the",
"four",
"instance",
"assignment",
"operators",
"(",
"="
] | 6ae64f2bb6ecbbe9db356e20e8ac94e85bdeed3a | https://github.com/SystemRDL/systemrdl-compiler/blob/6ae64f2bb6ecbbe9db356e20e8ac94e85bdeed3a/systemrdl/core/ComponentVisitor.py#L311-L323 | train |
SystemRDL/systemrdl-compiler | systemrdl/core/ComponentVisitor.py | ComponentVisitor.visitParam_def | def visitParam_def(self, ctx:SystemRDLParser.Param_defContext):
"""
Parameter Definition block
"""
self.compiler.namespace.enter_scope()
param_defs = []
for elem in ctx.getTypedRuleContexts(SystemRDLParser.Param_def_elemContext):
param_def = self.visit(elem)
... | python | def visitParam_def(self, ctx:SystemRDLParser.Param_defContext):
"""
Parameter Definition block
"""
self.compiler.namespace.enter_scope()
param_defs = []
for elem in ctx.getTypedRuleContexts(SystemRDLParser.Param_def_elemContext):
param_def = self.visit(elem)
... | [
"def",
"visitParam_def",
"(",
"self",
",",
"ctx",
":",
"SystemRDLParser",
".",
"Param_defContext",
")",
":",
"self",
".",
"compiler",
".",
"namespace",
".",
"enter_scope",
"(",
")",
"param_defs",
"=",
"[",
"]",
"for",
"elem",
"in",
"ctx",
".",
"getTypedRul... | Parameter Definition block | [
"Parameter",
"Definition",
"block"
] | 6ae64f2bb6ecbbe9db356e20e8ac94e85bdeed3a | https://github.com/SystemRDL/systemrdl-compiler/blob/6ae64f2bb6ecbbe9db356e20e8ac94e85bdeed3a/systemrdl/core/ComponentVisitor.py#L471-L483 | train |
SystemRDL/systemrdl-compiler | systemrdl/core/ComponentVisitor.py | ComponentVisitor.visitParam_def_elem | def visitParam_def_elem(self, ctx:SystemRDLParser.Param_def_elemContext):
"""
Individual parameter definition elements
"""
# Construct parameter type
data_type_token = self.visit(ctx.data_type())
param_data_type = self.datatype_from_token(data_type_token)
if ctx.... | python | def visitParam_def_elem(self, ctx:SystemRDLParser.Param_def_elemContext):
"""
Individual parameter definition elements
"""
# Construct parameter type
data_type_token = self.visit(ctx.data_type())
param_data_type = self.datatype_from_token(data_type_token)
if ctx.... | [
"def",
"visitParam_def_elem",
"(",
"self",
",",
"ctx",
":",
"SystemRDLParser",
".",
"Param_def_elemContext",
")",
":",
"data_type_token",
"=",
"self",
".",
"visit",
"(",
"ctx",
".",
"data_type",
"(",
")",
")",
"param_data_type",
"=",
"self",
".",
"datatype_fro... | Individual parameter definition elements | [
"Individual",
"parameter",
"definition",
"elements"
] | 6ae64f2bb6ecbbe9db356e20e8ac94e85bdeed3a | https://github.com/SystemRDL/systemrdl-compiler/blob/6ae64f2bb6ecbbe9db356e20e8ac94e85bdeed3a/systemrdl/core/ComponentVisitor.py#L485-L518 | train |
SystemRDL/systemrdl-compiler | systemrdl/core/BaseVisitor.py | BaseVisitor.datatype_from_token | def datatype_from_token(self, token):
"""
Given a SystemRDLParser token, lookup the type
This only includes types under the "data_type" grammar rule
"""
if token.type == SystemRDLParser.ID:
# Is an identifier for either an enum or struct type
typ = self.... | python | def datatype_from_token(self, token):
"""
Given a SystemRDLParser token, lookup the type
This only includes types under the "data_type" grammar rule
"""
if token.type == SystemRDLParser.ID:
# Is an identifier for either an enum or struct type
typ = self.... | [
"def",
"datatype_from_token",
"(",
"self",
",",
"token",
")",
":",
"if",
"token",
".",
"type",
"==",
"SystemRDLParser",
".",
"ID",
":",
"typ",
"=",
"self",
".",
"compiler",
".",
"namespace",
".",
"lookup_type",
"(",
"get_ID_text",
"(",
"token",
")",
")",... | Given a SystemRDLParser token, lookup the type
This only includes types under the "data_type" grammar rule | [
"Given",
"a",
"SystemRDLParser",
"token",
"lookup",
"the",
"type",
"This",
"only",
"includes",
"types",
"under",
"the",
"data_type",
"grammar",
"rule"
] | 6ae64f2bb6ecbbe9db356e20e8ac94e85bdeed3a | https://github.com/SystemRDL/systemrdl-compiler/blob/6ae64f2bb6ecbbe9db356e20e8ac94e85bdeed3a/systemrdl/core/BaseVisitor.py#L29-L54 | train |
SystemRDL/systemrdl-compiler | systemrdl/rdltypes.py | get_rdltype | def get_rdltype(value):
"""
Given a value, return the type identifier object used within the RDL compiler
If not a supported type, return None
"""
if isinstance(value, (int, bool, str)):
# Pass canonical types as-is
return type(value)
elif is_user_enum(type(value)):
retu... | python | def get_rdltype(value):
"""
Given a value, return the type identifier object used within the RDL compiler
If not a supported type, return None
"""
if isinstance(value, (int, bool, str)):
# Pass canonical types as-is
return type(value)
elif is_user_enum(type(value)):
retu... | [
"def",
"get_rdltype",
"(",
"value",
")",
":",
"if",
"isinstance",
"(",
"value",
",",
"(",
"int",
",",
"bool",
",",
"str",
")",
")",
":",
"return",
"type",
"(",
"value",
")",
"elif",
"is_user_enum",
"(",
"type",
"(",
"value",
")",
")",
":",
"return"... | Given a value, return the type identifier object used within the RDL compiler
If not a supported type, return None | [
"Given",
"a",
"value",
"return",
"the",
"type",
"identifier",
"object",
"used",
"within",
"the",
"RDL",
"compiler",
"If",
"not",
"a",
"supported",
"type",
"return",
"None"
] | 6ae64f2bb6ecbbe9db356e20e8ac94e85bdeed3a | https://github.com/SystemRDL/systemrdl-compiler/blob/6ae64f2bb6ecbbe9db356e20e8ac94e85bdeed3a/systemrdl/rdltypes.py#L507-L536 | train |
SystemRDL/systemrdl-compiler | systemrdl/rdltypes.py | UserEnum.get_html_desc | def get_html_desc(self, markdown_inst=None):
"""
Translates the enum's 'desc' property into HTML.
Any RDLFormatCode tags used in the description are converted to HTML.
The text is also fed through a Markdown processor.
The additional Markdown processing allows designers the cho... | python | def get_html_desc(self, markdown_inst=None):
"""
Translates the enum's 'desc' property into HTML.
Any RDLFormatCode tags used in the description are converted to HTML.
The text is also fed through a Markdown processor.
The additional Markdown processing allows designers the cho... | [
"def",
"get_html_desc",
"(",
"self",
",",
"markdown_inst",
"=",
"None",
")",
":",
"desc_str",
"=",
"self",
".",
"_rdl_desc_",
"if",
"desc_str",
"is",
"None",
":",
"return",
"None",
"return",
"rdlformatcode",
".",
"rdlfc_to_html",
"(",
"desc_str",
",",
"md",
... | Translates the enum's 'desc' property into HTML.
Any RDLFormatCode tags used in the description are converted to HTML.
The text is also fed through a Markdown processor.
The additional Markdown processing allows designers the choice to use a
more modern lightweight markup language as a... | [
"Translates",
"the",
"enum",
"s",
"desc",
"property",
"into",
"HTML",
"."
] | 6ae64f2bb6ecbbe9db356e20e8ac94e85bdeed3a | https://github.com/SystemRDL/systemrdl-compiler/blob/6ae64f2bb6ecbbe9db356e20e8ac94e85bdeed3a/systemrdl/rdltypes.py#L147-L174 | train |
SystemRDL/systemrdl-compiler | systemrdl/rdltypes.py | UserEnum.get_scope_path | def get_scope_path(cls, scope_separator="::"):
"""
Generate a string that represents this enum's declaration namespace
scope.
Parameters
----------
scope_separator: str
Override the separator between namespace scopes
"""
if cls.get_parent_scop... | python | def get_scope_path(cls, scope_separator="::"):
"""
Generate a string that represents this enum's declaration namespace
scope.
Parameters
----------
scope_separator: str
Override the separator between namespace scopes
"""
if cls.get_parent_scop... | [
"def",
"get_scope_path",
"(",
"cls",
",",
"scope_separator",
"=",
"\"::\"",
")",
":",
"if",
"cls",
".",
"get_parent_scope",
"(",
")",
"is",
"None",
":",
"return",
"\"\"",
"elif",
"isinstance",
"(",
"cls",
".",
"get_parent_scope",
"(",
")",
",",
"comp",
"... | Generate a string that represents this enum's declaration namespace
scope.
Parameters
----------
scope_separator: str
Override the separator between namespace scopes | [
"Generate",
"a",
"string",
"that",
"represents",
"this",
"enum",
"s",
"declaration",
"namespace",
"scope",
"."
] | 6ae64f2bb6ecbbe9db356e20e8ac94e85bdeed3a | https://github.com/SystemRDL/systemrdl-compiler/blob/6ae64f2bb6ecbbe9db356e20e8ac94e85bdeed3a/systemrdl/rdltypes.py#L188-L211 | train |
SystemRDL/systemrdl-compiler | systemrdl/rdltypes.py | UserStruct.define_new | def define_new(cls, name, members, is_abstract=False):
"""
Define a new struct type derived from the current type.
Parameters
----------
name: str
Name of the struct type
members: {member_name : type}
Dictionary of struct member types.
is_... | python | def define_new(cls, name, members, is_abstract=False):
"""
Define a new struct type derived from the current type.
Parameters
----------
name: str
Name of the struct type
members: {member_name : type}
Dictionary of struct member types.
is_... | [
"def",
"define_new",
"(",
"cls",
",",
"name",
",",
"members",
",",
"is_abstract",
"=",
"False",
")",
":",
"m",
"=",
"OrderedDict",
"(",
"cls",
".",
"_members",
")",
"if",
"set",
"(",
"m",
".",
"keys",
"(",
")",
")",
"&",
"set",
"(",
"members",
".... | Define a new struct type derived from the current type.
Parameters
----------
name: str
Name of the struct type
members: {member_name : type}
Dictionary of struct member types.
is_abstract: bool
If set, marks the struct as abstract. | [
"Define",
"a",
"new",
"struct",
"type",
"derived",
"from",
"the",
"current",
"type",
"."
] | 6ae64f2bb6ecbbe9db356e20e8ac94e85bdeed3a | https://github.com/SystemRDL/systemrdl-compiler/blob/6ae64f2bb6ecbbe9db356e20e8ac94e85bdeed3a/systemrdl/rdltypes.py#L288-L314 | train |
SystemRDL/systemrdl-compiler | systemrdl/compiler.py | RDLCompiler.define_udp | def define_udp(self, name, valid_type, valid_components=None, default=None):
"""
Pre-define a user-defined property.
This is the equivalent to the following RDL:
.. code-block:: none
property <name> {
type = <valid_type>;
component = <valid_... | python | def define_udp(self, name, valid_type, valid_components=None, default=None):
"""
Pre-define a user-defined property.
This is the equivalent to the following RDL:
.. code-block:: none
property <name> {
type = <valid_type>;
component = <valid_... | [
"def",
"define_udp",
"(",
"self",
",",
"name",
",",
"valid_type",
",",
"valid_components",
"=",
"None",
",",
"default",
"=",
"None",
")",
":",
"if",
"valid_components",
"is",
"None",
":",
"valid_components",
"=",
"[",
"comp",
".",
"Field",
",",
"comp",
"... | Pre-define a user-defined property.
This is the equivalent to the following RDL:
.. code-block:: none
property <name> {
type = <valid_type>;
component = <valid_components>;
default = <default>
};
Parameters
-----... | [
"Pre",
"-",
"define",
"a",
"user",
"-",
"defined",
"property",
"."
] | 6ae64f2bb6ecbbe9db356e20e8ac94e85bdeed3a | https://github.com/SystemRDL/systemrdl-compiler/blob/6ae64f2bb6ecbbe9db356e20e8ac94e85bdeed3a/systemrdl/compiler.py#L47-L91 | train |
SystemRDL/systemrdl-compiler | systemrdl/compiler.py | RDLCompiler.compile_file | def compile_file(self, path, incl_search_paths=None):
"""
Parse & compile a single file and append it to RDLCompiler's root
namespace.
If any exceptions (:class:`~systemrdl.RDLCompileError` or other)
occur during compilation, then the RDLCompiler object should be discarded.
... | python | def compile_file(self, path, incl_search_paths=None):
"""
Parse & compile a single file and append it to RDLCompiler's root
namespace.
If any exceptions (:class:`~systemrdl.RDLCompileError` or other)
occur during compilation, then the RDLCompiler object should be discarded.
... | [
"def",
"compile_file",
"(",
"self",
",",
"path",
",",
"incl_search_paths",
"=",
"None",
")",
":",
"if",
"incl_search_paths",
"is",
"None",
":",
"incl_search_paths",
"=",
"[",
"]",
"fpp",
"=",
"preprocessor",
".",
"FilePreprocessor",
"(",
"self",
".",
"env",
... | Parse & compile a single file and append it to RDLCompiler's root
namespace.
If any exceptions (:class:`~systemrdl.RDLCompileError` or other)
occur during compilation, then the RDLCompiler object should be discarded.
Parameters
----------
path:str
Path to an... | [
"Parse",
"&",
"compile",
"a",
"single",
"file",
"and",
"append",
"it",
"to",
"RDLCompiler",
"s",
"root",
"namespace",
"."
] | 6ae64f2bb6ecbbe9db356e20e8ac94e85bdeed3a | https://github.com/SystemRDL/systemrdl-compiler/blob/6ae64f2bb6ecbbe9db356e20e8ac94e85bdeed3a/systemrdl/compiler.py#L94-L152 | train |
SystemRDL/systemrdl-compiler | systemrdl/compiler.py | RDLCompiler.elaborate | def elaborate(self, top_def_name=None, inst_name=None, parameters=None):
"""
Elaborates the design for the given top-level addrmap component.
During elaboration, the following occurs:
- An instance of the ``$root`` meta-component is created.
- The addrmap component specified by... | python | def elaborate(self, top_def_name=None, inst_name=None, parameters=None):
"""
Elaborates the design for the given top-level addrmap component.
During elaboration, the following occurs:
- An instance of the ``$root`` meta-component is created.
- The addrmap component specified by... | [
"def",
"elaborate",
"(",
"self",
",",
"top_def_name",
"=",
"None",
",",
"inst_name",
"=",
"None",
",",
"parameters",
"=",
"None",
")",
":",
"if",
"parameters",
"is",
"None",
":",
"parameters",
"=",
"{",
"}",
"if",
"top_def_name",
"is",
"not",
"None",
"... | Elaborates the design for the given top-level addrmap component.
During elaboration, the following occurs:
- An instance of the ``$root`` meta-component is created.
- The addrmap component specified by ``top_def_name`` is instantiated as a
child of ``$root``.
- Expressions, p... | [
"Elaborates",
"the",
"design",
"for",
"the",
"given",
"top",
"-",
"level",
"addrmap",
"component",
"."
] | 6ae64f2bb6ecbbe9db356e20e8ac94e85bdeed3a | https://github.com/SystemRDL/systemrdl-compiler/blob/6ae64f2bb6ecbbe9db356e20e8ac94e85bdeed3a/systemrdl/compiler.py#L154-L285 | train |
SystemRDL/systemrdl-compiler | systemrdl/core/properties.py | PropertyRuleBoolPair.get_default | def get_default(self, node):
"""
If not explicitly set, check if the opposite was set first before returning
default
"""
if self.opposite_property in node.inst.properties:
return not node.inst.properties[self.opposite_property]
else:
return self.de... | python | def get_default(self, node):
"""
If not explicitly set, check if the opposite was set first before returning
default
"""
if self.opposite_property in node.inst.properties:
return not node.inst.properties[self.opposite_property]
else:
return self.de... | [
"def",
"get_default",
"(",
"self",
",",
"node",
")",
":",
"if",
"self",
".",
"opposite_property",
"in",
"node",
".",
"inst",
".",
"properties",
":",
"return",
"not",
"node",
".",
"inst",
".",
"properties",
"[",
"self",
".",
"opposite_property",
"]",
"els... | If not explicitly set, check if the opposite was set first before returning
default | [
"If",
"not",
"explicitly",
"set",
"check",
"if",
"the",
"opposite",
"was",
"set",
"first",
"before",
"returning",
"default"
] | 6ae64f2bb6ecbbe9db356e20e8ac94e85bdeed3a | https://github.com/SystemRDL/systemrdl-compiler/blob/6ae64f2bb6ecbbe9db356e20e8ac94e85bdeed3a/systemrdl/core/properties.py#L165-L173 | train |
SystemRDL/systemrdl-compiler | systemrdl/core/properties.py | Prop_rset.get_default | def get_default(self, node):
"""
If not explicitly set, check if onread sets the equivalent
"""
if node.inst.properties.get("onread", None) == rdltypes.OnReadType.rset:
return True
else:
return self.default | python | def get_default(self, node):
"""
If not explicitly set, check if onread sets the equivalent
"""
if node.inst.properties.get("onread", None) == rdltypes.OnReadType.rset:
return True
else:
return self.default | [
"def",
"get_default",
"(",
"self",
",",
"node",
")",
":",
"if",
"node",
".",
"inst",
".",
"properties",
".",
"get",
"(",
"\"onread\"",
",",
"None",
")",
"==",
"rdltypes",
".",
"OnReadType",
".",
"rset",
":",
"return",
"True",
"else",
":",
"return",
"... | If not explicitly set, check if onread sets the equivalent | [
"If",
"not",
"explicitly",
"set",
"check",
"if",
"onread",
"sets",
"the",
"equivalent"
] | 6ae64f2bb6ecbbe9db356e20e8ac94e85bdeed3a | https://github.com/SystemRDL/systemrdl-compiler/blob/6ae64f2bb6ecbbe9db356e20e8ac94e85bdeed3a/systemrdl/core/properties.py#L622-L629 | train |
SystemRDL/systemrdl-compiler | systemrdl/core/properties.py | Prop_onread.assign_value | def assign_value(self, comp_def, value, src_ref):
"""
Overrides other related properties
"""
super().assign_value(comp_def, value, src_ref)
if "rclr" in comp_def.properties:
del comp_def.properties["rclr"]
if "rset" in comp_def.properties:
del comp... | python | def assign_value(self, comp_def, value, src_ref):
"""
Overrides other related properties
"""
super().assign_value(comp_def, value, src_ref)
if "rclr" in comp_def.properties:
del comp_def.properties["rclr"]
if "rset" in comp_def.properties:
del comp... | [
"def",
"assign_value",
"(",
"self",
",",
"comp_def",
",",
"value",
",",
"src_ref",
")",
":",
"super",
"(",
")",
".",
"assign_value",
"(",
"comp_def",
",",
"value",
",",
"src_ref",
")",
"if",
"\"rclr\"",
"in",
"comp_def",
".",
"properties",
":",
"del",
... | Overrides other related properties | [
"Overrides",
"other",
"related",
"properties"
] | 6ae64f2bb6ecbbe9db356e20e8ac94e85bdeed3a | https://github.com/SystemRDL/systemrdl-compiler/blob/6ae64f2bb6ecbbe9db356e20e8ac94e85bdeed3a/systemrdl/core/properties.py#L642-L650 | train |
SystemRDL/systemrdl-compiler | systemrdl/core/properties.py | Prop_onread.get_default | def get_default(self, node):
"""
If not explicitly set, check if rset or rclr imply the value
"""
if node.inst.properties.get("rset", False):
return rdltypes.OnReadType.rset
elif node.inst.properties.get("rclr", False):
return rdltypes.OnReadType.rclr
... | python | def get_default(self, node):
"""
If not explicitly set, check if rset or rclr imply the value
"""
if node.inst.properties.get("rset", False):
return rdltypes.OnReadType.rset
elif node.inst.properties.get("rclr", False):
return rdltypes.OnReadType.rclr
... | [
"def",
"get_default",
"(",
"self",
",",
"node",
")",
":",
"if",
"node",
".",
"inst",
".",
"properties",
".",
"get",
"(",
"\"rset\"",
",",
"False",
")",
":",
"return",
"rdltypes",
".",
"OnReadType",
".",
"rset",
"elif",
"node",
".",
"inst",
".",
"prop... | If not explicitly set, check if rset or rclr imply the value | [
"If",
"not",
"explicitly",
"set",
"check",
"if",
"rset",
"or",
"rclr",
"imply",
"the",
"value"
] | 6ae64f2bb6ecbbe9db356e20e8ac94e85bdeed3a | https://github.com/SystemRDL/systemrdl-compiler/blob/6ae64f2bb6ecbbe9db356e20e8ac94e85bdeed3a/systemrdl/core/properties.py#L652-L661 | train |
SystemRDL/systemrdl-compiler | systemrdl/core/properties.py | Prop_woclr.get_default | def get_default(self, node):
"""
If not explicitly set, check if onwrite sets the equivalent
"""
if node.inst.properties.get("onwrite", None) == rdltypes.OnWriteType.woclr:
return True
else:
return self.default | python | def get_default(self, node):
"""
If not explicitly set, check if onwrite sets the equivalent
"""
if node.inst.properties.get("onwrite", None) == rdltypes.OnWriteType.woclr:
return True
else:
return self.default | [
"def",
"get_default",
"(",
"self",
",",
"node",
")",
":",
"if",
"node",
".",
"inst",
".",
"properties",
".",
"get",
"(",
"\"onwrite\"",
",",
"None",
")",
"==",
"rdltypes",
".",
"OnWriteType",
".",
"woclr",
":",
"return",
"True",
"else",
":",
"return",
... | If not explicitly set, check if onwrite sets the equivalent | [
"If",
"not",
"explicitly",
"set",
"check",
"if",
"onwrite",
"sets",
"the",
"equivalent"
] | 6ae64f2bb6ecbbe9db356e20e8ac94e85bdeed3a | https://github.com/SystemRDL/systemrdl-compiler/blob/6ae64f2bb6ecbbe9db356e20e8ac94e85bdeed3a/systemrdl/core/properties.py#L702-L709 | train |
SystemRDL/systemrdl-compiler | systemrdl/core/properties.py | Prop_onwrite.get_default | def get_default(self, node):
"""
If not explicitly set, check if woset or woclr imply the value
"""
if node.inst.properties.get("woset", False):
return rdltypes.OnWriteType.woset
elif node.inst.properties.get("woclr", False):
return rdltypes.OnWriteType.wo... | python | def get_default(self, node):
"""
If not explicitly set, check if woset or woclr imply the value
"""
if node.inst.properties.get("woset", False):
return rdltypes.OnWriteType.woset
elif node.inst.properties.get("woclr", False):
return rdltypes.OnWriteType.wo... | [
"def",
"get_default",
"(",
"self",
",",
"node",
")",
":",
"if",
"node",
".",
"inst",
".",
"properties",
".",
"get",
"(",
"\"woset\"",
",",
"False",
")",
":",
"return",
"rdltypes",
".",
"OnWriteType",
".",
"woset",
"elif",
"node",
".",
"inst",
".",
"p... | If not explicitly set, check if woset or woclr imply the value | [
"If",
"not",
"explicitly",
"set",
"check",
"if",
"woset",
"or",
"woclr",
"imply",
"the",
"value"
] | 6ae64f2bb6ecbbe9db356e20e8ac94e85bdeed3a | https://github.com/SystemRDL/systemrdl-compiler/blob/6ae64f2bb6ecbbe9db356e20e8ac94e85bdeed3a/systemrdl/core/properties.py#L762-L771 | train |
SystemRDL/systemrdl-compiler | systemrdl/core/properties.py | Prop_threshold.assign_value | def assign_value(self, comp_def, value, src_ref):
"""
Set both alias and actual value
"""
super().assign_value(comp_def, value, src_ref)
comp_def.properties['incrthreshold'] = value | python | def assign_value(self, comp_def, value, src_ref):
"""
Set both alias and actual value
"""
super().assign_value(comp_def, value, src_ref)
comp_def.properties['incrthreshold'] = value | [
"def",
"assign_value",
"(",
"self",
",",
"comp_def",
",",
"value",
",",
"src_ref",
")",
":",
"super",
"(",
")",
".",
"assign_value",
"(",
"comp_def",
",",
"value",
",",
"src_ref",
")",
"comp_def",
".",
"properties",
"[",
"'incrthreshold'",
"]",
"=",
"val... | Set both alias and actual value | [
"Set",
"both",
"alias",
"and",
"actual",
"value"
] | 6ae64f2bb6ecbbe9db356e20e8ac94e85bdeed3a | https://github.com/SystemRDL/systemrdl-compiler/blob/6ae64f2bb6ecbbe9db356e20e8ac94e85bdeed3a/systemrdl/core/properties.py#L1008-L1013 | train |
SystemRDL/systemrdl-compiler | systemrdl/core/properties.py | Prop_stickybit.get_default | def get_default(self, node):
"""
Unless specified otherwise, intr fields are implicitly stickybit
"""
if node.inst.properties.get("intr", False):
# Interrupt is set!
# Default is implicitly stickybit, unless the mutually-exclusive
# sticky property was... | python | def get_default(self, node):
"""
Unless specified otherwise, intr fields are implicitly stickybit
"""
if node.inst.properties.get("intr", False):
# Interrupt is set!
# Default is implicitly stickybit, unless the mutually-exclusive
# sticky property was... | [
"def",
"get_default",
"(",
"self",
",",
"node",
")",
":",
"if",
"node",
".",
"inst",
".",
"properties",
".",
"get",
"(",
"\"intr\"",
",",
"False",
")",
":",
"return",
"not",
"node",
".",
"inst",
".",
"properties",
".",
"get",
"(",
"\"sticky\"",
",",
... | Unless specified otherwise, intr fields are implicitly stickybit | [
"Unless",
"specified",
"otherwise",
"intr",
"fields",
"are",
"implicitly",
"stickybit"
] | 6ae64f2bb6ecbbe9db356e20e8ac94e85bdeed3a | https://github.com/SystemRDL/systemrdl-compiler/blob/6ae64f2bb6ecbbe9db356e20e8ac94e85bdeed3a/systemrdl/core/properties.py#L1198-L1208 | train |
SystemRDL/systemrdl-compiler | systemrdl/core/elaborate.py | StructuralPlacementListener.resolve_addresses | def resolve_addresses(self, node):
"""
Resolve addresses of children of Addrmap and Regfile components
"""
# Get alignment based on 'alignment' property
# This remains constant for all children
prop_alignment = self.alignment_stack[-1]
if prop_alignment is None:
... | python | def resolve_addresses(self, node):
"""
Resolve addresses of children of Addrmap and Regfile components
"""
# Get alignment based on 'alignment' property
# This remains constant for all children
prop_alignment = self.alignment_stack[-1]
if prop_alignment is None:
... | [
"def",
"resolve_addresses",
"(",
"self",
",",
"node",
")",
":",
"prop_alignment",
"=",
"self",
".",
"alignment_stack",
"[",
"-",
"1",
"]",
"if",
"prop_alignment",
"is",
"None",
":",
"prop_alignment",
"=",
"1",
"prev_node",
"=",
"None",
"for",
"child_node",
... | Resolve addresses of children of Addrmap and Regfile components | [
"Resolve",
"addresses",
"of",
"children",
"of",
"Addrmap",
"and",
"Regfile",
"components"
] | 6ae64f2bb6ecbbe9db356e20e8ac94e85bdeed3a | https://github.com/SystemRDL/systemrdl-compiler/blob/6ae64f2bb6ecbbe9db356e20e8ac94e85bdeed3a/systemrdl/core/elaborate.py#L408-L488 | train |
SystemRDL/systemrdl-compiler | systemrdl/core/helpers.py | get_ID_text | def get_ID_text(token):
"""
Get the text from the ID token.
Strips off leading slash escape if present
"""
if isinstance(token, CommonToken):
text = token.text
else:
text = token.getText()
text = text.lstrip('\\')
return text | python | def get_ID_text(token):
"""
Get the text from the ID token.
Strips off leading slash escape if present
"""
if isinstance(token, CommonToken):
text = token.text
else:
text = token.getText()
text = text.lstrip('\\')
return text | [
"def",
"get_ID_text",
"(",
"token",
")",
":",
"if",
"isinstance",
"(",
"token",
",",
"CommonToken",
")",
":",
"text",
"=",
"token",
".",
"text",
"else",
":",
"text",
"=",
"token",
".",
"getText",
"(",
")",
"text",
"=",
"text",
".",
"lstrip",
"(",
"... | Get the text from the ID token.
Strips off leading slash escape if present | [
"Get",
"the",
"text",
"from",
"the",
"ID",
"token",
".",
"Strips",
"off",
"leading",
"slash",
"escape",
"if",
"present"
] | 6ae64f2bb6ecbbe9db356e20e8ac94e85bdeed3a | https://github.com/SystemRDL/systemrdl-compiler/blob/6ae64f2bb6ecbbe9db356e20e8ac94e85bdeed3a/systemrdl/core/helpers.py#L16-L27 | train |
SystemRDL/systemrdl-compiler | systemrdl/preprocessor/segment_map.py | SegmentMap.derive_source_offset | def derive_source_offset(self, offset, is_end=False):
"""
Given a post-preprocessed coordinate, derives the corresponding coordinate
in the original source file.
Returns result in the following tuple:
(src_offset, src_path, include_ref)
where:
- src_offse... | python | def derive_source_offset(self, offset, is_end=False):
"""
Given a post-preprocessed coordinate, derives the corresponding coordinate
in the original source file.
Returns result in the following tuple:
(src_offset, src_path, include_ref)
where:
- src_offse... | [
"def",
"derive_source_offset",
"(",
"self",
",",
"offset",
",",
"is_end",
"=",
"False",
")",
":",
"for",
"segment",
"in",
"self",
".",
"segments",
":",
"if",
"offset",
"<=",
"segment",
".",
"end",
":",
"if",
"isinstance",
"(",
"segment",
",",
"MacroSegme... | Given a post-preprocessed coordinate, derives the corresponding coordinate
in the original source file.
Returns result in the following tuple:
(src_offset, src_path, include_ref)
where:
- src_offset is the translated coordinate
If the input offset lands o... | [
"Given",
"a",
"post",
"-",
"preprocessed",
"coordinate",
"derives",
"the",
"corresponding",
"coordinate",
"in",
"the",
"original",
"source",
"file",
"."
] | 6ae64f2bb6ecbbe9db356e20e8ac94e85bdeed3a | https://github.com/SystemRDL/systemrdl-compiler/blob/6ae64f2bb6ecbbe9db356e20e8ac94e85bdeed3a/systemrdl/preprocessor/segment_map.py#L8-L50 | train |
SystemRDL/systemrdl-compiler | systemrdl/preprocessor/preprocessor.py | FilePreprocessor.preprocess | def preprocess(self):
"""
Run preprocessor on a top-level file.
Performs the following preprocess steps:
- Expand `include directives
- Perl Preprocessor
Returns
-------
tuple
(preprocessed_text, SegmentMap)
"""
tokens = self... | python | def preprocess(self):
"""
Run preprocessor on a top-level file.
Performs the following preprocess steps:
- Expand `include directives
- Perl Preprocessor
Returns
-------
tuple
(preprocessed_text, SegmentMap)
"""
tokens = self... | [
"def",
"preprocess",
"(",
"self",
")",
":",
"tokens",
"=",
"self",
".",
"tokenize",
"(",
")",
"pl_segments",
",",
"has_perl_tags",
"=",
"self",
".",
"get_perl_segments",
"(",
"tokens",
")",
"str_parts",
"=",
"[",
"]",
"smap",
"=",
"segment_map",
".",
"Se... | Run preprocessor on a top-level file.
Performs the following preprocess steps:
- Expand `include directives
- Perl Preprocessor
Returns
-------
tuple
(preprocessed_text, SegmentMap) | [
"Run",
"preprocessor",
"on",
"a",
"top",
"-",
"level",
"file",
"."
] | 6ae64f2bb6ecbbe9db356e20e8ac94e85bdeed3a | https://github.com/SystemRDL/systemrdl-compiler/blob/6ae64f2bb6ecbbe9db356e20e8ac94e85bdeed3a/systemrdl/preprocessor/preprocessor.py#L26-L93 | train |
SystemRDL/systemrdl-compiler | systemrdl/preprocessor/preprocessor.py | FilePreprocessor.tokenize | def tokenize(self):
"""
Tokenize the input text
Scans for instances of perl tags and include directives.
Tokenization skips line and block comments.
Returns
-------
list
List of tuples: (typ, start, end)
Where:
- typ is "per... | python | def tokenize(self):
"""
Tokenize the input text
Scans for instances of perl tags and include directives.
Tokenization skips line and block comments.
Returns
-------
list
List of tuples: (typ, start, end)
Where:
- typ is "per... | [
"def",
"tokenize",
"(",
"self",
")",
":",
"tokens",
"=",
"[",
"]",
"token_spec",
"=",
"[",
"(",
"'mlc'",
",",
"r'/\\*.*?\\*/'",
")",
",",
"(",
"'slc'",
",",
"r'//[^\\r\\n]*?\\r?\\n'",
")",
",",
"(",
"'perl'",
",",
"r'<%.*?%>'",
")",
",",
"(",
"'incl'",... | Tokenize the input text
Scans for instances of perl tags and include directives.
Tokenization skips line and block comments.
Returns
-------
list
List of tuples: (typ, start, end)
Where:
- typ is "perl" or "incl"
- start/end mar... | [
"Tokenize",
"the",
"input",
"text"
] | 6ae64f2bb6ecbbe9db356e20e8ac94e85bdeed3a | https://github.com/SystemRDL/systemrdl-compiler/blob/6ae64f2bb6ecbbe9db356e20e8ac94e85bdeed3a/systemrdl/preprocessor/preprocessor.py#L96-L124 | train |
SystemRDL/systemrdl-compiler | systemrdl/preprocessor/preprocessor.py | FilePreprocessor.parse_include | def parse_include(self, start):
"""
Extract include from text based on start position of token
Returns
-------
(end, incl_path)
- end: last char in include
- incl_path: Resolved path to include
"""
# Seek back to start of line
i = ... | python | def parse_include(self, start):
"""
Extract include from text based on start position of token
Returns
-------
(end, incl_path)
- end: last char in include
- incl_path: Resolved path to include
"""
# Seek back to start of line
i = ... | [
"def",
"parse_include",
"(",
"self",
",",
"start",
")",
":",
"i",
"=",
"start",
"while",
"i",
":",
"if",
"self",
".",
"text",
"[",
"i",
"]",
"==",
"'\\n'",
":",
"i",
"+=",
"1",
"break",
"i",
"-=",
"1",
"line_start",
"=",
"i",
"if",
"not",
"(",
... | Extract include from text based on start position of token
Returns
-------
(end, incl_path)
- end: last char in include
- incl_path: Resolved path to include | [
"Extract",
"include",
"from",
"text",
"based",
"on",
"start",
"position",
"of",
"token"
] | 6ae64f2bb6ecbbe9db356e20e8ac94e85bdeed3a | https://github.com/SystemRDL/systemrdl-compiler/blob/6ae64f2bb6ecbbe9db356e20e8ac94e85bdeed3a/systemrdl/preprocessor/preprocessor.py#L127-L204 | train |
SystemRDL/systemrdl-compiler | systemrdl/preprocessor/preprocessor.py | FilePreprocessor.run_perl_miniscript | def run_perl_miniscript(self, segments):
"""
Generates and runs a perl miniscript that derives the text that will be
emitted from the preprocessor
returns the resulting emit list
"""
# Check if perl is installed
if shutil.which("perl") is None:
self.... | python | def run_perl_miniscript(self, segments):
"""
Generates and runs a perl miniscript that derives the text that will be
emitted from the preprocessor
returns the resulting emit list
"""
# Check if perl is installed
if shutil.which("perl") is None:
self.... | [
"def",
"run_perl_miniscript",
"(",
"self",
",",
"segments",
")",
":",
"if",
"shutil",
".",
"which",
"(",
"\"perl\"",
")",
"is",
"None",
":",
"self",
".",
"env",
".",
"msg",
".",
"fatal",
"(",
"\"Input contains Perl preprocessor tags, but an installation of Perl co... | Generates and runs a perl miniscript that derives the text that will be
emitted from the preprocessor
returns the resulting emit list | [
"Generates",
"and",
"runs",
"a",
"perl",
"miniscript",
"that",
"derives",
"the",
"text",
"that",
"will",
"be",
"emitted",
"from",
"the",
"preprocessor"
] | 6ae64f2bb6ecbbe9db356e20e8ac94e85bdeed3a | https://github.com/SystemRDL/systemrdl-compiler/blob/6ae64f2bb6ecbbe9db356e20e8ac94e85bdeed3a/systemrdl/preprocessor/preprocessor.py#L264-L323 | train |
SystemRDL/systemrdl-compiler | systemrdl/core/namespace.py | NamespaceRegistry.get_default_properties | def get_default_properties(self, comp_type):
"""
Returns a flattened dictionary of all default property assignments
visible in the current scope that apply to the current component type.
"""
# Flatten out all the default assignments that apply to the current scope
# This ... | python | def get_default_properties(self, comp_type):
"""
Returns a flattened dictionary of all default property assignments
visible in the current scope that apply to the current component type.
"""
# Flatten out all the default assignments that apply to the current scope
# This ... | [
"def",
"get_default_properties",
"(",
"self",
",",
"comp_type",
")",
":",
"props",
"=",
"{",
"}",
"for",
"scope",
"in",
"self",
".",
"default_property_ns_stack",
"[",
":",
"-",
"1",
"]",
":",
"props",
".",
"update",
"(",
"scope",
")",
"prop_names",
"=",
... | Returns a flattened dictionary of all default property assignments
visible in the current scope that apply to the current component type. | [
"Returns",
"a",
"flattened",
"dictionary",
"of",
"all",
"default",
"property",
"assignments",
"visible",
"in",
"the",
"current",
"scope",
"that",
"apply",
"to",
"the",
"current",
"component",
"type",
"."
] | 6ae64f2bb6ecbbe9db356e20e8ac94e85bdeed3a | https://github.com/SystemRDL/systemrdl-compiler/blob/6ae64f2bb6ecbbe9db356e20e8ac94e85bdeed3a/systemrdl/core/namespace.py#L59-L83 | train |
SystemRDL/systemrdl-compiler | systemrdl/component.py | Component.get_scope_path | def get_scope_path(self, scope_separator="::"):
"""
Generate a string that represents this component's declaration namespace
scope.
Parameters
----------
scope_separator: str
Override the separator between namespace scopes
"""
if self.parent_s... | python | def get_scope_path(self, scope_separator="::"):
"""
Generate a string that represents this component's declaration namespace
scope.
Parameters
----------
scope_separator: str
Override the separator between namespace scopes
"""
if self.parent_s... | [
"def",
"get_scope_path",
"(",
"self",
",",
"scope_separator",
"=",
"\"::\"",
")",
":",
"if",
"self",
".",
"parent_scope",
"is",
"None",
":",
"return",
"\"\"",
"elif",
"isinstance",
"(",
"self",
".",
"parent_scope",
",",
"Root",
")",
":",
"return",
"\"\"",
... | Generate a string that represents this component's declaration namespace
scope.
Parameters
----------
scope_separator: str
Override the separator between namespace scopes | [
"Generate",
"a",
"string",
"that",
"represents",
"this",
"component",
"s",
"declaration",
"namespace",
"scope",
"."
] | 6ae64f2bb6ecbbe9db356e20e8ac94e85bdeed3a | https://github.com/SystemRDL/systemrdl-compiler/blob/6ae64f2bb6ecbbe9db356e20e8ac94e85bdeed3a/systemrdl/component.py#L112-L135 | train |
SystemRDL/systemrdl-compiler | systemrdl/component.py | AddressableComponent.n_elements | def n_elements(self):
"""
Total number of array elements.
If array is multidimensional, array is flattened.
Returns 1 if not an array.
"""
if self.is_array:
return functools.reduce(operator.mul, self.array_dimensions)
else:
return 1 | python | def n_elements(self):
"""
Total number of array elements.
If array is multidimensional, array is flattened.
Returns 1 if not an array.
"""
if self.is_array:
return functools.reduce(operator.mul, self.array_dimensions)
else:
return 1 | [
"def",
"n_elements",
"(",
"self",
")",
":",
"if",
"self",
".",
"is_array",
":",
"return",
"functools",
".",
"reduce",
"(",
"operator",
".",
"mul",
",",
"self",
".",
"array_dimensions",
")",
"else",
":",
"return",
"1"
] | Total number of array elements.
If array is multidimensional, array is flattened.
Returns 1 if not an array. | [
"Total",
"number",
"of",
"array",
"elements",
".",
"If",
"array",
"is",
"multidimensional",
"array",
"is",
"flattened",
".",
"Returns",
"1",
"if",
"not",
"an",
"array",
"."
] | 6ae64f2bb6ecbbe9db356e20e8ac94e85bdeed3a | https://github.com/SystemRDL/systemrdl-compiler/blob/6ae64f2bb6ecbbe9db356e20e8ac94e85bdeed3a/systemrdl/component.py#L171-L180 | train |
SystemRDL/systemrdl-compiler | systemrdl/walker.py | RDLWalker.walk | def walk(self, node, *listeners:RDLListener):
"""
Initiates the walker to traverse the current ``node`` and its children.
Calls the corresponding callback for each of the ``listeners`` provided in
the order that they are listed.
Parameters
----------
node : :clas... | python | def walk(self, node, *listeners:RDLListener):
"""
Initiates the walker to traverse the current ``node`` and its children.
Calls the corresponding callback for each of the ``listeners`` provided in
the order that they are listed.
Parameters
----------
node : :clas... | [
"def",
"walk",
"(",
"self",
",",
"node",
",",
"*",
"listeners",
":",
"RDLListener",
")",
":",
"for",
"listener",
"in",
"listeners",
":",
"self",
".",
"do_enter",
"(",
"node",
",",
"listener",
")",
"for",
"child",
"in",
"node",
".",
"children",
"(",
"... | Initiates the walker to traverse the current ``node`` and its children.
Calls the corresponding callback for each of the ``listeners`` provided in
the order that they are listed.
Parameters
----------
node : :class:`~systemrdl.node.Node`
Node to start traversing.
... | [
"Initiates",
"the",
"walker",
"to",
"traverse",
"the",
"current",
"node",
"and",
"its",
"children",
".",
"Calls",
"the",
"corresponding",
"callback",
"for",
"each",
"of",
"the",
"listeners",
"provided",
"in",
"the",
"order",
"that",
"they",
"are",
"listed",
... | 6ae64f2bb6ecbbe9db356e20e8ac94e85bdeed3a | https://github.com/SystemRDL/systemrdl-compiler/blob/6ae64f2bb6ecbbe9db356e20e8ac94e85bdeed3a/systemrdl/walker.py#L99-L124 | train |
elmotec/massedit | massedit.py | get_function | def get_function(fn_name):
"""Retrieve the function defined by the function_name.
Arguments:
fn_name: specification of the type module:function_name.
"""
module_name, callable_name = fn_name.split(':')
current = globals()
if not callable_name:
callable_name = module_name
else... | python | def get_function(fn_name):
"""Retrieve the function defined by the function_name.
Arguments:
fn_name: specification of the type module:function_name.
"""
module_name, callable_name = fn_name.split(':')
current = globals()
if not callable_name:
callable_name = module_name
else... | [
"def",
"get_function",
"(",
"fn_name",
")",
":",
"module_name",
",",
"callable_name",
"=",
"fn_name",
".",
"split",
"(",
"':'",
")",
"current",
"=",
"globals",
"(",
")",
"if",
"not",
"callable_name",
":",
"callable_name",
"=",
"module_name",
"else",
":",
"... | Retrieve the function defined by the function_name.
Arguments:
fn_name: specification of the type module:function_name. | [
"Retrieve",
"the",
"function",
"defined",
"by",
"the",
"function_name",
"."
] | 57e22787354896d63a8850312314b19aa0308906 | https://github.com/elmotec/massedit/blob/57e22787354896d63a8850312314b19aa0308906/massedit.py#L66-L90 | train |
elmotec/massedit | massedit.py | parse_command_line | def parse_command_line(argv):
"""Parse command line argument. See -h option.
Arguments:
argv: arguments on the command line must include caller file name.
"""
import textwrap
example = textwrap.dedent("""
Examples:
# Simple string substitution (-e). Will show a diff. No changes appl... | python | def parse_command_line(argv):
"""Parse command line argument. See -h option.
Arguments:
argv: arguments on the command line must include caller file name.
"""
import textwrap
example = textwrap.dedent("""
Examples:
# Simple string substitution (-e). Will show a diff. No changes appl... | [
"def",
"parse_command_line",
"(",
"argv",
")",
":",
"import",
"textwrap",
"example",
"=",
"textwrap",
".",
"dedent",
"(",
")",
".",
"format",
"(",
"os",
".",
"path",
".",
"basename",
"(",
"argv",
"[",
"0",
"]",
")",
")",
"formatter_class",
"=",
"argpar... | Parse command line argument. See -h option.
Arguments:
argv: arguments on the command line must include caller file name. | [
"Parse",
"command",
"line",
"argument",
".",
"See",
"-",
"h",
"option",
"."
] | 57e22787354896d63a8850312314b19aa0308906 | https://github.com/elmotec/massedit/blob/57e22787354896d63a8850312314b19aa0308906/massedit.py#L332-L402 | train |
elmotec/massedit | massedit.py | get_paths | def get_paths(patterns, start_dirs=None, max_depth=1):
"""Retrieve files that match any of the patterns."""
# Shortcut: if there is only one pattern, make sure we process just that.
if len(patterns) == 1 and not start_dirs:
pattern = patterns[0]
directory = os.path.dirname(pattern)
i... | python | def get_paths(patterns, start_dirs=None, max_depth=1):
"""Retrieve files that match any of the patterns."""
# Shortcut: if there is only one pattern, make sure we process just that.
if len(patterns) == 1 and not start_dirs:
pattern = patterns[0]
directory = os.path.dirname(pattern)
i... | [
"def",
"get_paths",
"(",
"patterns",
",",
"start_dirs",
"=",
"None",
",",
"max_depth",
"=",
"1",
")",
":",
"if",
"len",
"(",
"patterns",
")",
"==",
"1",
"and",
"not",
"start_dirs",
":",
"pattern",
"=",
"patterns",
"[",
"0",
"]",
"directory",
"=",
"os... | Retrieve files that match any of the patterns. | [
"Retrieve",
"files",
"that",
"match",
"any",
"of",
"the",
"patterns",
"."
] | 57e22787354896d63a8850312314b19aa0308906 | https://github.com/elmotec/massedit/blob/57e22787354896d63a8850312314b19aa0308906/massedit.py#L405-L430 | train |
elmotec/massedit | massedit.py | edit_files | def edit_files(patterns, expressions=None,
functions=None, executables=None,
start_dirs=None, max_depth=1, dry_run=True,
output=sys.stdout, encoding=None, newline=None):
"""Process patterns with MassEdit.
Arguments:
patterns: file pattern to identify the files... | python | def edit_files(patterns, expressions=None,
functions=None, executables=None,
start_dirs=None, max_depth=1, dry_run=True,
output=sys.stdout, encoding=None, newline=None):
"""Process patterns with MassEdit.
Arguments:
patterns: file pattern to identify the files... | [
"def",
"edit_files",
"(",
"patterns",
",",
"expressions",
"=",
"None",
",",
"functions",
"=",
"None",
",",
"executables",
"=",
"None",
",",
"start_dirs",
"=",
"None",
",",
"max_depth",
"=",
"1",
",",
"dry_run",
"=",
"True",
",",
"output",
"=",
"sys",
"... | Process patterns with MassEdit.
Arguments:
patterns: file pattern to identify the files to be processed.
expressions: single python expression to be applied line by line.
functions: functions to process files contents.
executables: os executables to execute on the argument files.
Keywo... | [
"Process",
"patterns",
"with",
"MassEdit",
"."
] | 57e22787354896d63a8850312314b19aa0308906 | https://github.com/elmotec/massedit/blob/57e22787354896d63a8850312314b19aa0308906/massedit.py#L469-L530 | train |
elmotec/massedit | massedit.py | command_line | def command_line(argv):
"""Instantiate an editor and process arguments.
Optional argument:
- processed_paths: paths processed are appended to the list.
"""
arguments = parse_command_line(argv)
if arguments.generate:
generate_fixer_file(arguments.generate)
paths = edit_files(argum... | python | def command_line(argv):
"""Instantiate an editor and process arguments.
Optional argument:
- processed_paths: paths processed are appended to the list.
"""
arguments = parse_command_line(argv)
if arguments.generate:
generate_fixer_file(arguments.generate)
paths = edit_files(argum... | [
"def",
"command_line",
"(",
"argv",
")",
":",
"arguments",
"=",
"parse_command_line",
"(",
"argv",
")",
"if",
"arguments",
".",
"generate",
":",
"generate_fixer_file",
"(",
"arguments",
".",
"generate",
")",
"paths",
"=",
"edit_files",
"(",
"arguments",
".",
... | Instantiate an editor and process arguments.
Optional argument:
- processed_paths: paths processed are appended to the list. | [
"Instantiate",
"an",
"editor",
"and",
"process",
"arguments",
"."
] | 57e22787354896d63a8850312314b19aa0308906 | https://github.com/elmotec/massedit/blob/57e22787354896d63a8850312314b19aa0308906/massedit.py#L533-L558 | train |
elmotec/massedit | massedit.py | MassEdit.import_module | def import_module(module): # pylint: disable=R0201
"""Import module that are needed for the code expr to compile.
Argument:
module (str or list): module(s) to import.
"""
if isinstance(module, list):
all_modules = module
else:
all_modules = [m... | python | def import_module(module): # pylint: disable=R0201
"""Import module that are needed for the code expr to compile.
Argument:
module (str or list): module(s) to import.
"""
if isinstance(module, list):
all_modules = module
else:
all_modules = [m... | [
"def",
"import_module",
"(",
"module",
")",
":",
"if",
"isinstance",
"(",
"module",
",",
"list",
")",
":",
"all_modules",
"=",
"module",
"else",
":",
"all_modules",
"=",
"[",
"module",
"]",
"for",
"mod",
"in",
"all_modules",
":",
"globals",
"(",
")",
"... | Import module that are needed for the code expr to compile.
Argument:
module (str or list): module(s) to import. | [
"Import",
"module",
"that",
"are",
"needed",
"for",
"the",
"code",
"expr",
"to",
"compile",
"."
] | 57e22787354896d63a8850312314b19aa0308906 | https://github.com/elmotec/massedit/blob/57e22787354896d63a8850312314b19aa0308906/massedit.py#L131-L143 | train |
elmotec/massedit | massedit.py | MassEdit.__edit_line | def __edit_line(line, code, code_obj): # pylint: disable=R0201
"""Edit a line with one code object built in the ctor."""
try:
# pylint: disable=eval-used
result = eval(code_obj, globals(), locals())
except TypeError as ex:
log.error("failed to execute %s: %s"... | python | def __edit_line(line, code, code_obj): # pylint: disable=R0201
"""Edit a line with one code object built in the ctor."""
try:
# pylint: disable=eval-used
result = eval(code_obj, globals(), locals())
except TypeError as ex:
log.error("failed to execute %s: %s"... | [
"def",
"__edit_line",
"(",
"line",
",",
"code",
",",
"code_obj",
")",
":",
"try",
":",
"result",
"=",
"eval",
"(",
"code_obj",
",",
"globals",
"(",
")",
",",
"locals",
"(",
")",
")",
"except",
"TypeError",
"as",
"ex",
":",
"log",
".",
"error",
"(",... | Edit a line with one code object built in the ctor. | [
"Edit",
"a",
"line",
"with",
"one",
"code",
"object",
"built",
"in",
"the",
"ctor",
"."
] | 57e22787354896d63a8850312314b19aa0308906 | https://github.com/elmotec/massedit/blob/57e22787354896d63a8850312314b19aa0308906/massedit.py#L146-L162 | train |
elmotec/massedit | massedit.py | MassEdit.edit_line | def edit_line(self, line):
"""Edit a single line using the code expression."""
for code, code_obj in self.code_objs.items():
line = self.__edit_line(line, code, code_obj)
return line | python | def edit_line(self, line):
"""Edit a single line using the code expression."""
for code, code_obj in self.code_objs.items():
line = self.__edit_line(line, code, code_obj)
return line | [
"def",
"edit_line",
"(",
"self",
",",
"line",
")",
":",
"for",
"code",
",",
"code_obj",
"in",
"self",
".",
"code_objs",
".",
"items",
"(",
")",
":",
"line",
"=",
"self",
".",
"__edit_line",
"(",
"line",
",",
"code",
",",
"code_obj",
")",
"return",
... | Edit a single line using the code expression. | [
"Edit",
"a",
"single",
"line",
"using",
"the",
"code",
"expression",
"."
] | 57e22787354896d63a8850312314b19aa0308906 | https://github.com/elmotec/massedit/blob/57e22787354896d63a8850312314b19aa0308906/massedit.py#L164-L168 | train |
elmotec/massedit | massedit.py | MassEdit.edit_content | def edit_content(self, original_lines, file_name):
"""Processes a file contents.
First processes the contents line by line applying the registered
expressions, then process the resulting contents using the
registered functions.
Arguments:
original_lines (list of str):... | python | def edit_content(self, original_lines, file_name):
"""Processes a file contents.
First processes the contents line by line applying the registered
expressions, then process the resulting contents using the
registered functions.
Arguments:
original_lines (list of str):... | [
"def",
"edit_content",
"(",
"self",
",",
"original_lines",
",",
"file_name",
")",
":",
"lines",
"=",
"[",
"self",
".",
"edit_line",
"(",
"line",
")",
"for",
"line",
"in",
"original_lines",
"]",
"for",
"function",
"in",
"self",
".",
"_functions",
":",
"tr... | Processes a file contents.
First processes the contents line by line applying the registered
expressions, then process the resulting contents using the
registered functions.
Arguments:
original_lines (list of str): file content.
file_name (str): name of the file. | [
"Processes",
"a",
"file",
"contents",
"."
] | 57e22787354896d63a8850312314b19aa0308906 | https://github.com/elmotec/massedit/blob/57e22787354896d63a8850312314b19aa0308906/massedit.py#L170-L193 | train |
elmotec/massedit | massedit.py | MassEdit.append_code_expr | def append_code_expr(self, code):
"""Compile argument and adds it to the list of code objects."""
# expects a string.
if isinstance(code, str) and not isinstance(code, unicode):
code = unicode(code)
if not isinstance(code, unicode):
raise TypeError("string expecte... | python | def append_code_expr(self, code):
"""Compile argument and adds it to the list of code objects."""
# expects a string.
if isinstance(code, str) and not isinstance(code, unicode):
code = unicode(code)
if not isinstance(code, unicode):
raise TypeError("string expecte... | [
"def",
"append_code_expr",
"(",
"self",
",",
"code",
")",
":",
"if",
"isinstance",
"(",
"code",
",",
"str",
")",
"and",
"not",
"isinstance",
"(",
"code",
",",
"unicode",
")",
":",
"code",
"=",
"unicode",
"(",
"code",
")",
"if",
"not",
"isinstance",
"... | Compile argument and adds it to the list of code objects. | [
"Compile",
"argument",
"and",
"adds",
"it",
"to",
"the",
"list",
"of",
"code",
"objects",
"."
] | 57e22787354896d63a8850312314b19aa0308906 | https://github.com/elmotec/massedit/blob/57e22787354896d63a8850312314b19aa0308906/massedit.py#L262-L276 | train |
elmotec/massedit | massedit.py | MassEdit.append_function | def append_function(self, function):
"""Append the function to the list of functions to be called.
If the function is already a callable, use it. If it's a type str
try to interpret it as [module]:?<callable>, load the module
if there is one and retrieve the callable.
Argument:... | python | def append_function(self, function):
"""Append the function to the list of functions to be called.
If the function is already a callable, use it. If it's a type str
try to interpret it as [module]:?<callable>, load the module
if there is one and retrieve the callable.
Argument:... | [
"def",
"append_function",
"(",
"self",
",",
"function",
")",
":",
"if",
"not",
"hasattr",
"(",
"function",
",",
"'__call__'",
")",
":",
"function",
"=",
"get_function",
"(",
"function",
")",
"if",
"not",
"hasattr",
"(",
"function",
",",
"'__call__'",
")",
... | Append the function to the list of functions to be called.
If the function is already a callable, use it. If it's a type str
try to interpret it as [module]:?<callable>, load the module
if there is one and retrieve the callable.
Argument:
function (str or callable): function ... | [
"Append",
"the",
"function",
"to",
"the",
"list",
"of",
"functions",
"to",
"be",
"called",
"."
] | 57e22787354896d63a8850312314b19aa0308906 | https://github.com/elmotec/massedit/blob/57e22787354896d63a8850312314b19aa0308906/massedit.py#L278-L294 | train |
elmotec/massedit | massedit.py | MassEdit.append_executable | def append_executable(self, executable):
"""Append san executable os command to the list to be called.
Argument:
executable (str): os callable executable.
"""
if isinstance(executable, str) and not isinstance(executable, unicode):
executable = unicode(executable)
... | python | def append_executable(self, executable):
"""Append san executable os command to the list to be called.
Argument:
executable (str): os callable executable.
"""
if isinstance(executable, str) and not isinstance(executable, unicode):
executable = unicode(executable)
... | [
"def",
"append_executable",
"(",
"self",
",",
"executable",
")",
":",
"if",
"isinstance",
"(",
"executable",
",",
"str",
")",
"and",
"not",
"isinstance",
"(",
"executable",
",",
"unicode",
")",
":",
"executable",
"=",
"unicode",
"(",
"executable",
")",
"if... | Append san executable os command to the list to be called.
Argument:
executable (str): os callable executable. | [
"Append",
"san",
"executable",
"os",
"command",
"to",
"the",
"list",
"to",
"be",
"called",
"."
] | 57e22787354896d63a8850312314b19aa0308906 | https://github.com/elmotec/massedit/blob/57e22787354896d63a8850312314b19aa0308906/massedit.py#L296-L308 | train |
elmotec/massedit | massedit.py | MassEdit.set_functions | def set_functions(self, functions):
"""Check functions passed as argument and set them to be used."""
for func in functions:
try:
self.append_function(func)
except (ValueError, AttributeError) as ex:
log.error("'%s' is not a callable function: %s",... | python | def set_functions(self, functions):
"""Check functions passed as argument and set them to be used."""
for func in functions:
try:
self.append_function(func)
except (ValueError, AttributeError) as ex:
log.error("'%s' is not a callable function: %s",... | [
"def",
"set_functions",
"(",
"self",
",",
"functions",
")",
":",
"for",
"func",
"in",
"functions",
":",
"try",
":",
"self",
".",
"append_function",
"(",
"func",
")",
"except",
"(",
"ValueError",
",",
"AttributeError",
")",
"as",
"ex",
":",
"log",
".",
... | Check functions passed as argument and set them to be used. | [
"Check",
"functions",
"passed",
"as",
"argument",
"and",
"set",
"them",
"to",
"be",
"used",
"."
] | 57e22787354896d63a8850312314b19aa0308906 | https://github.com/elmotec/massedit/blob/57e22787354896d63a8850312314b19aa0308906/massedit.py#L317-L324 | train |
wonambi-python/wonambi | wonambi/ioeeg/mnefiff.py | write_mnefiff | def write_mnefiff(data, filename):
"""Export data to MNE using FIFF format.
Parameters
----------
data : instance of ChanTime
data with only one trial
filename : path to file
file to export to (include '.mat')
Notes
-----
It cannot store data larger than 2 GB.
The d... | python | def write_mnefiff(data, filename):
"""Export data to MNE using FIFF format.
Parameters
----------
data : instance of ChanTime
data with only one trial
filename : path to file
file to export to (include '.mat')
Notes
-----
It cannot store data larger than 2 GB.
The d... | [
"def",
"write_mnefiff",
"(",
"data",
",",
"filename",
")",
":",
"from",
"mne",
"import",
"create_info",
",",
"set_log_level",
"from",
"mne",
".",
"io",
"import",
"RawArray",
"set_log_level",
"(",
"WARNING",
")",
"TRIAL",
"=",
"0",
"info",
"=",
"create_info",... | Export data to MNE using FIFF format.
Parameters
----------
data : instance of ChanTime
data with only one trial
filename : path to file
file to export to (include '.mat')
Notes
-----
It cannot store data larger than 2 GB.
The data is assumed to have only EEG electrodes... | [
"Export",
"data",
"to",
"MNE",
"using",
"FIFF",
"format",
"."
] | 1d8e3d7e53df8017c199f703bcab582914676e76 | https://github.com/wonambi-python/wonambi/blob/1d8e3d7e53df8017c199f703bcab582914676e76/wonambi/ioeeg/mnefiff.py#L5-L37 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.