repository_name stringlengths 5 67 | func_path_in_repository stringlengths 4 234 | func_name stringlengths 0 314 | whole_func_string stringlengths 52 3.87M | language stringclasses 6
values | func_code_string stringlengths 52 3.87M | func_documentation_string stringlengths 1 47.2k | func_code_url stringlengths 85 339 |
|---|---|---|---|---|---|---|---|
IAMconsortium/pyam | pyam/core.py | IamDataFrame.rename | def rename(self, mapping=None, inplace=False, append=False,
check_duplicates=True, **kwargs):
"""Rename and aggregate column entries using `groupby.sum()` on values.
When renaming models or scenarios, the uniqueness of the index must be
maintained, and the function will raise an e... | python | def rename(self, mapping=None, inplace=False, append=False,
check_duplicates=True, **kwargs):
"""Rename and aggregate column entries using `groupby.sum()` on values.
When renaming models or scenarios, the uniqueness of the index must be
maintained, and the function will raise an e... | Rename and aggregate column entries using `groupby.sum()` on values.
When renaming models or scenarios, the uniqueness of the index must be
maintained, and the function will raise an error otherwise.
Renaming is only applied to any data where a filter matches for all
columns given in `m... | https://github.com/IAMconsortium/pyam/blob/4077929ca6e7be63a0e3ecf882c5f1da97b287bf/pyam/core.py#L543-L633 |
IAMconsortium/pyam | pyam/core.py | IamDataFrame.convert_unit | def convert_unit(self, conversion_mapping, inplace=False):
"""Converts units based on provided unit conversion factors
Parameters
----------
conversion_mapping: dict
for each unit for which a conversion should be carried out,
provide current unit and target unit ... | python | def convert_unit(self, conversion_mapping, inplace=False):
"""Converts units based on provided unit conversion factors
Parameters
----------
conversion_mapping: dict
for each unit for which a conversion should be carried out,
provide current unit and target unit ... | Converts units based on provided unit conversion factors
Parameters
----------
conversion_mapping: dict
for each unit for which a conversion should be carried out,
provide current unit and target unit and conversion factor
{<current unit>: [<target unit>, <co... | https://github.com/IAMconsortium/pyam/blob/4077929ca6e7be63a0e3ecf882c5f1da97b287bf/pyam/core.py#L635-L654 |
IAMconsortium/pyam | pyam/core.py | IamDataFrame.normalize | def normalize(self, inplace=False, **kwargs):
"""Normalize data to a given value. Currently only supports normalizing
to a specific time.
Parameters
----------
inplace: bool, default False
if True, do operation inplace and return None
kwargs: the values on wh... | python | def normalize(self, inplace=False, **kwargs):
"""Normalize data to a given value. Currently only supports normalizing
to a specific time.
Parameters
----------
inplace: bool, default False
if True, do operation inplace and return None
kwargs: the values on wh... | Normalize data to a given value. Currently only supports normalizing
to a specific time.
Parameters
----------
inplace: bool, default False
if True, do operation inplace and return None
kwargs: the values on which to normalize (e.g., `year=2005`) | https://github.com/IAMconsortium/pyam/blob/4077929ca6e7be63a0e3ecf882c5f1da97b287bf/pyam/core.py#L656-L677 |
IAMconsortium/pyam | pyam/core.py | IamDataFrame.aggregate | def aggregate(self, variable, components=None, append=False):
"""Compute the aggregate of timeseries components or sub-categories
Parameters
----------
variable: str
variable for which the aggregate should be computed
components: list of str, default None
... | python | def aggregate(self, variable, components=None, append=False):
"""Compute the aggregate of timeseries components or sub-categories
Parameters
----------
variable: str
variable for which the aggregate should be computed
components: list of str, default None
... | Compute the aggregate of timeseries components or sub-categories
Parameters
----------
variable: str
variable for which the aggregate should be computed
components: list of str, default None
list of variables, defaults to all sub-categories of `variable`
... | https://github.com/IAMconsortium/pyam/blob/4077929ca6e7be63a0e3ecf882c5f1da97b287bf/pyam/core.py#L679-L707 |
IAMconsortium/pyam | pyam/core.py | IamDataFrame.check_aggregate | def check_aggregate(self, variable, components=None, exclude_on_fail=False,
multiplier=1, **kwargs):
"""Check whether a timeseries matches the aggregation of its components
Parameters
----------
variable: str
variable to be checked for matching aggreg... | python | def check_aggregate(self, variable, components=None, exclude_on_fail=False,
multiplier=1, **kwargs):
"""Check whether a timeseries matches the aggregation of its components
Parameters
----------
variable: str
variable to be checked for matching aggreg... | Check whether a timeseries matches the aggregation of its components
Parameters
----------
variable: str
variable to be checked for matching aggregation of sub-categories
components: list of str, default None
list of variables, defaults to all sub-categories of `... | https://github.com/IAMconsortium/pyam/blob/4077929ca6e7be63a0e3ecf882c5f1da97b287bf/pyam/core.py#L709-L747 |
IAMconsortium/pyam | pyam/core.py | IamDataFrame.aggregate_region | def aggregate_region(self, variable, region='World', subregions=None,
components=None, append=False):
"""Compute the aggregate of timeseries over a number of regions
including variable components only defined at the `region` level
Parameters
----------
v... | python | def aggregate_region(self, variable, region='World', subregions=None,
components=None, append=False):
"""Compute the aggregate of timeseries over a number of regions
including variable components only defined at the `region` level
Parameters
----------
v... | Compute the aggregate of timeseries over a number of regions
including variable components only defined at the `region` level
Parameters
----------
variable: str
variable for which the aggregate should be computed
region: str, default 'World'
dimension
... | https://github.com/IAMconsortium/pyam/blob/4077929ca6e7be63a0e3ecf882c5f1da97b287bf/pyam/core.py#L749-L801 |
IAMconsortium/pyam | pyam/core.py | IamDataFrame.check_aggregate_region | def check_aggregate_region(self, variable, region='World', subregions=None,
components=None, exclude_on_fail=False,
**kwargs):
"""Check whether the region timeseries data match the aggregation
of components
Parameters
-------... | python | def check_aggregate_region(self, variable, region='World', subregions=None,
components=None, exclude_on_fail=False,
**kwargs):
"""Check whether the region timeseries data match the aggregation
of components
Parameters
-------... | Check whether the region timeseries data match the aggregation
of components
Parameters
----------
variable: str
variable to be checked for matching aggregation of subregions
region: str, default 'World'
region to be checked for matching aggregation of su... | https://github.com/IAMconsortium/pyam/blob/4077929ca6e7be63a0e3ecf882c5f1da97b287bf/pyam/core.py#L803-L850 |
IAMconsortium/pyam | pyam/core.py | IamDataFrame._variable_components | def _variable_components(self, variable):
"""Get all components (sub-categories) of a variable
For `variable='foo'`, return `['foo|bar']`, but don't include
`'foo|bar|baz'`, which is a sub-sub-category"""
var_list = pd.Series(self.data.variable.unique())
return var_list[pattern_... | python | def _variable_components(self, variable):
"""Get all components (sub-categories) of a variable
For `variable='foo'`, return `['foo|bar']`, but don't include
`'foo|bar|baz'`, which is a sub-sub-category"""
var_list = pd.Series(self.data.variable.unique())
return var_list[pattern_... | Get all components (sub-categories) of a variable
For `variable='foo'`, return `['foo|bar']`, but don't include
`'foo|bar|baz'`, which is a sub-sub-category | https://github.com/IAMconsortium/pyam/blob/4077929ca6e7be63a0e3ecf882c5f1da97b287bf/pyam/core.py#L852-L858 |
IAMconsortium/pyam | pyam/core.py | IamDataFrame.check_internal_consistency | def check_internal_consistency(self, **kwargs):
"""Check whether the database is internally consistent
We check that all variables are equal to the sum of their sectoral
components and that all the regions add up to the World total. If
the check is passed, None is returned, otherwise a ... | python | def check_internal_consistency(self, **kwargs):
"""Check whether the database is internally consistent
We check that all variables are equal to the sum of their sectoral
components and that all the regions add up to the World total. If
the check is passed, None is returned, otherwise a ... | Check whether the database is internally consistent
We check that all variables are equal to the sum of their sectoral
components and that all the regions add up to the World total. If
the check is passed, None is returned, otherwise a dictionary of
inconsistent variables is returned.
... | https://github.com/IAMconsortium/pyam/blob/4077929ca6e7be63a0e3ecf882c5f1da97b287bf/pyam/core.py#L860-L888 |
IAMconsortium/pyam | pyam/core.py | IamDataFrame._exclude_on_fail | def _exclude_on_fail(self, df):
"""Assign a selection of scenarios as `exclude: True` in meta"""
idx = df if isinstance(df, pd.MultiIndex) else _meta_idx(df)
self.meta.loc[idx, 'exclude'] = True
logger().info('{} non-valid scenario{} will be excluded'
.format(len(id... | python | def _exclude_on_fail(self, df):
"""Assign a selection of scenarios as `exclude: True` in meta"""
idx = df if isinstance(df, pd.MultiIndex) else _meta_idx(df)
self.meta.loc[idx, 'exclude'] = True
logger().info('{} non-valid scenario{} will be excluded'
.format(len(id... | Assign a selection of scenarios as `exclude: True` in meta | https://github.com/IAMconsortium/pyam/blob/4077929ca6e7be63a0e3ecf882c5f1da97b287bf/pyam/core.py#L890-L895 |
IAMconsortium/pyam | pyam/core.py | IamDataFrame.filter | def filter(self, filters=None, keep=True, inplace=False, **kwargs):
"""Return a filtered IamDataFrame (i.e., a subset of current data)
Parameters
----------
keep: bool, default True
keep all scenarios satisfying the filters (if True) or the inverse
inplace: bool, def... | python | def filter(self, filters=None, keep=True, inplace=False, **kwargs):
"""Return a filtered IamDataFrame (i.e., a subset of current data)
Parameters
----------
keep: bool, default True
keep all scenarios satisfying the filters (if True) or the inverse
inplace: bool, def... | Return a filtered IamDataFrame (i.e., a subset of current data)
Parameters
----------
keep: bool, default True
keep all scenarios satisfying the filters (if True) or the inverse
inplace: bool, default False
if True, do operation inplace and return None
fi... | https://github.com/IAMconsortium/pyam/blob/4077929ca6e7be63a0e3ecf882c5f1da97b287bf/pyam/core.py#L897-L936 |
IAMconsortium/pyam | pyam/core.py | IamDataFrame._apply_filters | def _apply_filters(self, **filters):
"""Determine rows to keep in data for given set of filters
Parameters
----------
filters: dict
dictionary of filters ({col: values}}); uses a pseudo-regexp syntax
by default, but accepts `regexp: True` to use regexp directly
... | python | def _apply_filters(self, **filters):
"""Determine rows to keep in data for given set of filters
Parameters
----------
filters: dict
dictionary of filters ({col: values}}); uses a pseudo-regexp syntax
by default, but accepts `regexp: True` to use regexp directly
... | Determine rows to keep in data for given set of filters
Parameters
----------
filters: dict
dictionary of filters ({col: values}}); uses a pseudo-regexp syntax
by default, but accepts `regexp: True` to use regexp directly | https://github.com/IAMconsortium/pyam/blob/4077929ca6e7be63a0e3ecf882c5f1da97b287bf/pyam/core.py#L938-L1013 |
IAMconsortium/pyam | pyam/core.py | IamDataFrame.col_apply | def col_apply(self, col, func, *args, **kwargs):
"""Apply a function to a column
Parameters
----------
col: string
column in either data or metadata
func: functional
function to apply
"""
if col in self.data:
self.data[col] = s... | python | def col_apply(self, col, func, *args, **kwargs):
"""Apply a function to a column
Parameters
----------
col: string
column in either data or metadata
func: functional
function to apply
"""
if col in self.data:
self.data[col] = s... | Apply a function to a column
Parameters
----------
col: string
column in either data or metadata
func: functional
function to apply | https://github.com/IAMconsortium/pyam/blob/4077929ca6e7be63a0e3ecf882c5f1da97b287bf/pyam/core.py#L1015-L1028 |
IAMconsortium/pyam | pyam/core.py | IamDataFrame._to_file_format | def _to_file_format(self, iamc_index):
"""Return a dataframe suitable for writing to a file"""
df = self.timeseries(iamc_index=iamc_index).reset_index()
df = df.rename(columns={c: str(c).title() for c in df.columns})
return df | python | def _to_file_format(self, iamc_index):
"""Return a dataframe suitable for writing to a file"""
df = self.timeseries(iamc_index=iamc_index).reset_index()
df = df.rename(columns={c: str(c).title() for c in df.columns})
return df | Return a dataframe suitable for writing to a file | https://github.com/IAMconsortium/pyam/blob/4077929ca6e7be63a0e3ecf882c5f1da97b287bf/pyam/core.py#L1030-L1034 |
IAMconsortium/pyam | pyam/core.py | IamDataFrame.to_csv | def to_csv(self, path, iamc_index=False, **kwargs):
"""Write timeseries data to a csv file
Parameters
----------
path: string
file path
iamc_index: bool, default False
if True, use `['model', 'scenario', 'region', 'variable', 'unit']`;
else, u... | python | def to_csv(self, path, iamc_index=False, **kwargs):
"""Write timeseries data to a csv file
Parameters
----------
path: string
file path
iamc_index: bool, default False
if True, use `['model', 'scenario', 'region', 'variable', 'unit']`;
else, u... | Write timeseries data to a csv file
Parameters
----------
path: string
file path
iamc_index: bool, default False
if True, use `['model', 'scenario', 'region', 'variable', 'unit']`;
else, use all `data` columns | https://github.com/IAMconsortium/pyam/blob/4077929ca6e7be63a0e3ecf882c5f1da97b287bf/pyam/core.py#L1036-L1047 |
IAMconsortium/pyam | pyam/core.py | IamDataFrame.to_excel | def to_excel(self, excel_writer, sheet_name='data',
iamc_index=False, **kwargs):
"""Write timeseries data to Excel format
Parameters
----------
excel_writer: string or ExcelWriter object
file path or existing ExcelWriter
sheet_name: string, default '... | python | def to_excel(self, excel_writer, sheet_name='data',
iamc_index=False, **kwargs):
"""Write timeseries data to Excel format
Parameters
----------
excel_writer: string or ExcelWriter object
file path or existing ExcelWriter
sheet_name: string, default '... | Write timeseries data to Excel format
Parameters
----------
excel_writer: string or ExcelWriter object
file path or existing ExcelWriter
sheet_name: string, default 'data'
name of sheet which will contain `IamDataFrame.timeseries()` data
iamc_index: bool,... | https://github.com/IAMconsortium/pyam/blob/4077929ca6e7be63a0e3ecf882c5f1da97b287bf/pyam/core.py#L1049-L1070 |
IAMconsortium/pyam | pyam/core.py | IamDataFrame.export_metadata | def export_metadata(self, path):
"""Export metadata to Excel
Parameters
----------
path: string
path/filename for xlsx file of metadata export
"""
writer = pd.ExcelWriter(path)
write_sheet(writer, 'meta', self.meta, index=True)
writer.save() | python | def export_metadata(self, path):
"""Export metadata to Excel
Parameters
----------
path: string
path/filename for xlsx file of metadata export
"""
writer = pd.ExcelWriter(path)
write_sheet(writer, 'meta', self.meta, index=True)
writer.save() | Export metadata to Excel
Parameters
----------
path: string
path/filename for xlsx file of metadata export | https://github.com/IAMconsortium/pyam/blob/4077929ca6e7be63a0e3ecf882c5f1da97b287bf/pyam/core.py#L1072-L1082 |
IAMconsortium/pyam | pyam/core.py | IamDataFrame.load_metadata | def load_metadata(self, path, *args, **kwargs):
"""Load metadata exported from `pyam.IamDataFrame` instance
Parameters
----------
path: string
xlsx file with metadata exported from `pyam.IamDataFrame` instance
"""
if not os.path.exists(path):
rais... | python | def load_metadata(self, path, *args, **kwargs):
"""Load metadata exported from `pyam.IamDataFrame` instance
Parameters
----------
path: string
xlsx file with metadata exported from `pyam.IamDataFrame` instance
"""
if not os.path.exists(path):
rais... | Load metadata exported from `pyam.IamDataFrame` instance
Parameters
----------
path: string
xlsx file with metadata exported from `pyam.IamDataFrame` instance | https://github.com/IAMconsortium/pyam/blob/4077929ca6e7be63a0e3ecf882c5f1da97b287bf/pyam/core.py#L1084-L1131 |
IAMconsortium/pyam | pyam/core.py | IamDataFrame.line_plot | def line_plot(self, x='year', y='value', **kwargs):
"""Plot timeseries lines of existing data
see pyam.plotting.line_plot() for all available options
"""
df = self.as_pandas(with_metadata=kwargs)
# pivot data if asked for explicit variable name
variables = df['variable'... | python | def line_plot(self, x='year', y='value', **kwargs):
"""Plot timeseries lines of existing data
see pyam.plotting.line_plot() for all available options
"""
df = self.as_pandas(with_metadata=kwargs)
# pivot data if asked for explicit variable name
variables = df['variable'... | Plot timeseries lines of existing data
see pyam.plotting.line_plot() for all available options | https://github.com/IAMconsortium/pyam/blob/4077929ca6e7be63a0e3ecf882c5f1da97b287bf/pyam/core.py#L1133-L1160 |
IAMconsortium/pyam | pyam/core.py | IamDataFrame.stack_plot | def stack_plot(self, *args, **kwargs):
"""Plot timeseries stacks of existing data
see pyam.plotting.stack_plot() for all available options
"""
df = self.as_pandas(with_metadata=True)
ax = plotting.stack_plot(df, *args, **kwargs)
return ax | python | def stack_plot(self, *args, **kwargs):
"""Plot timeseries stacks of existing data
see pyam.plotting.stack_plot() for all available options
"""
df = self.as_pandas(with_metadata=True)
ax = plotting.stack_plot(df, *args, **kwargs)
return ax | Plot timeseries stacks of existing data
see pyam.plotting.stack_plot() for all available options | https://github.com/IAMconsortium/pyam/blob/4077929ca6e7be63a0e3ecf882c5f1da97b287bf/pyam/core.py#L1162-L1169 |
IAMconsortium/pyam | pyam/core.py | IamDataFrame.scatter | def scatter(self, x, y, **kwargs):
"""Plot a scatter chart using metadata columns
see pyam.plotting.scatter() for all available options
"""
variables = self.data['variable'].unique()
xisvar = x in variables
yisvar = y in variables
if not xisvar and not yisvar:
... | python | def scatter(self, x, y, **kwargs):
"""Plot a scatter chart using metadata columns
see pyam.plotting.scatter() for all available options
"""
variables = self.data['variable'].unique()
xisvar = x in variables
yisvar = y in variables
if not xisvar and not yisvar:
... | Plot a scatter chart using metadata columns
see pyam.plotting.scatter() for all available options | https://github.com/IAMconsortium/pyam/blob/4077929ca6e7be63a0e3ecf882c5f1da97b287bf/pyam/core.py#L1189-L1229 |
IAMconsortium/pyam | pyam/core.py | IamDataFrame.map_regions | def map_regions(self, map_col, agg=None, copy_col=None, fname=None,
region_col=None, remove_duplicates=False, inplace=False):
"""Plot regional data for a single model, scenario, variable, and year
see pyam.plotting.region_plot() for all available options
Parameters
... | python | def map_regions(self, map_col, agg=None, copy_col=None, fname=None,
region_col=None, remove_duplicates=False, inplace=False):
"""Plot regional data for a single model, scenario, variable, and year
see pyam.plotting.region_plot() for all available options
Parameters
... | Plot regional data for a single model, scenario, variable, and year
see pyam.plotting.region_plot() for all available options
Parameters
----------
map_col: string
The column used to map new regions to. Common examples include
iso and 5_region.
agg: stri... | https://github.com/IAMconsortium/pyam/blob/4077929ca6e7be63a0e3ecf882c5f1da97b287bf/pyam/core.py#L1231-L1318 |
IAMconsortium/pyam | pyam/core.py | IamDataFrame.region_plot | def region_plot(self, **kwargs):
"""Plot regional data for a single model, scenario, variable, and year
see pyam.plotting.region_plot() for all available options
"""
df = self.as_pandas(with_metadata=True)
ax = plotting.region_plot(df, **kwargs)
return ax | python | def region_plot(self, **kwargs):
"""Plot regional data for a single model, scenario, variable, and year
see pyam.plotting.region_plot() for all available options
"""
df = self.as_pandas(with_metadata=True)
ax = plotting.region_plot(df, **kwargs)
return ax | Plot regional data for a single model, scenario, variable, and year
see pyam.plotting.region_plot() for all available options | https://github.com/IAMconsortium/pyam/blob/4077929ca6e7be63a0e3ecf882c5f1da97b287bf/pyam/core.py#L1320-L1327 |
IAMconsortium/pyam | pyam/run_control.py | RunControl.update | def update(self, rc):
"""Add additional run control parameters
Parameters
----------
rc : string, file, dictionary, optional
a path to a YAML file, a file handle for a YAML file, or a
dictionary describing run control configuration
"""
rc = self._... | python | def update(self, rc):
"""Add additional run control parameters
Parameters
----------
rc : string, file, dictionary, optional
a path to a YAML file, a file handle for a YAML file, or a
dictionary describing run control configuration
"""
rc = self._... | Add additional run control parameters
Parameters
----------
rc : string, file, dictionary, optional
a path to a YAML file, a file handle for a YAML file, or a
dictionary describing run control configuration | https://github.com/IAMconsortium/pyam/blob/4077929ca6e7be63a0e3ecf882c5f1da97b287bf/pyam/run_control.py#L75-L85 |
IAMconsortium/pyam | pyam/run_control.py | RunControl.recursive_update | def recursive_update(self, k, d):
"""Recursively update a top-level option in the run control
Parameters
----------
k : string
the top-level key
d : dictionary or similar
the dictionary to use for updating
"""
u = self.__getitem__(k)
... | python | def recursive_update(self, k, d):
"""Recursively update a top-level option in the run control
Parameters
----------
k : string
the top-level key
d : dictionary or similar
the dictionary to use for updating
"""
u = self.__getitem__(k)
... | Recursively update a top-level option in the run control
Parameters
----------
k : string
the top-level key
d : dictionary or similar
the dictionary to use for updating | https://github.com/IAMconsortium/pyam/blob/4077929ca6e7be63a0e3ecf882c5f1da97b287bf/pyam/run_control.py#L125-L136 |
IAMconsortium/pyam | pyam/timeseries.py | fill_series | def fill_series(x, year):
"""Returns the value of a timeseries (indexed over years) for a year
by linear interpolation.
Parameters
----------
x: pandas.Series
a timeseries to be interpolated
year: int
year of interpolation
"""
x = x.dropna()
if year in x.index and no... | python | def fill_series(x, year):
"""Returns the value of a timeseries (indexed over years) for a year
by linear interpolation.
Parameters
----------
x: pandas.Series
a timeseries to be interpolated
year: int
year of interpolation
"""
x = x.dropna()
if year in x.index and no... | Returns the value of a timeseries (indexed over years) for a year
by linear interpolation.
Parameters
----------
x: pandas.Series
a timeseries to be interpolated
year: int
year of interpolation | https://github.com/IAMconsortium/pyam/blob/4077929ca6e7be63a0e3ecf882c5f1da97b287bf/pyam/timeseries.py#L10-L32 |
IAMconsortium/pyam | pyam/timeseries.py | cumulative | def cumulative(x, first_year, last_year):
"""Returns the cumulative sum of a timeseries (indexed over years),
implements linear interpolation between years, ignores nan's in the range.
The function includes the last-year value of the series, and
raises a warning if start_year or last_year is outside of
... | python | def cumulative(x, first_year, last_year):
"""Returns the cumulative sum of a timeseries (indexed over years),
implements linear interpolation between years, ignores nan's in the range.
The function includes the last-year value of the series, and
raises a warning if start_year or last_year is outside of
... | Returns the cumulative sum of a timeseries (indexed over years),
implements linear interpolation between years, ignores nan's in the range.
The function includes the last-year value of the series, and
raises a warning if start_year or last_year is outside of
the timeseries range and returns nan
Par... | https://github.com/IAMconsortium/pyam/blob/4077929ca6e7be63a0e3ecf882c5f1da97b287bf/pyam/timeseries.py#L35-L86 |
IAMconsortium/pyam | pyam/timeseries.py | cross_threshold | def cross_threshold(x, threshold=0, direction=['from above', 'from below']):
"""Returns a list of the years in which a timeseries (indexed over years)
crosses a given threshold
Parameters
----------
x: pandas.Series
a timeseries indexed over years
threshold: float, default 0
the... | python | def cross_threshold(x, threshold=0, direction=['from above', 'from below']):
"""Returns a list of the years in which a timeseries (indexed over years)
crosses a given threshold
Parameters
----------
x: pandas.Series
a timeseries indexed over years
threshold: float, default 0
the... | Returns a list of the years in which a timeseries (indexed over years)
crosses a given threshold
Parameters
----------
x: pandas.Series
a timeseries indexed over years
threshold: float, default 0
the threshold that the timeseries is checked against
direction: str, optional, defa... | https://github.com/IAMconsortium/pyam/blob/4077929ca6e7be63a0e3ecf882c5f1da97b287bf/pyam/timeseries.py#L89-L123 |
IAMconsortium/pyam | pyam/iiasa.py | read_iiasa | def read_iiasa(name, meta=False, **kwargs):
"""
Query an IIASA database. See Connection.query() for more documentation
Parameters
----------
name : str
A valid IIASA database name, see pyam.iiasa.valid_connection_names()
meta : bool or list of strings
If not False, also include ... | python | def read_iiasa(name, meta=False, **kwargs):
"""
Query an IIASA database. See Connection.query() for more documentation
Parameters
----------
name : str
A valid IIASA database name, see pyam.iiasa.valid_connection_names()
meta : bool or list of strings
If not False, also include ... | Query an IIASA database. See Connection.query() for more documentation
Parameters
----------
name : str
A valid IIASA database name, see pyam.iiasa.valid_connection_names()
meta : bool or list of strings
If not False, also include metadata indicators (or subset if provided).
kwargs ... | https://github.com/IAMconsortium/pyam/blob/4077929ca6e7be63a0e3ecf882c5f1da97b287bf/pyam/iiasa.py#L256-L286 |
IAMconsortium/pyam | pyam/iiasa.py | Connection.scenario_list | def scenario_list(self, default=True):
"""
Metadata regarding the list of scenarios (e.g., models, scenarios,
run identifier, etc.) in the connected data source.
Parameter
---------
default : bool, optional, default True
Return *only* the default version of e... | python | def scenario_list(self, default=True):
"""
Metadata regarding the list of scenarios (e.g., models, scenarios,
run identifier, etc.) in the connected data source.
Parameter
---------
default : bool, optional, default True
Return *only* the default version of e... | Metadata regarding the list of scenarios (e.g., models, scenarios,
run identifier, etc.) in the connected data source.
Parameter
---------
default : bool, optional, default True
Return *only* the default version of each Scenario.
Any (`model`, `scenario`) without... | https://github.com/IAMconsortium/pyam/blob/4077929ca6e7be63a0e3ecf882c5f1da97b287bf/pyam/iiasa.py#L67-L84 |
IAMconsortium/pyam | pyam/iiasa.py | Connection.available_metadata | def available_metadata(self):
"""
List all scenario metadata indicators available in the connected
data source
"""
url = self.base_url + 'metadata/types'
headers = {'Authorization': 'Bearer {}'.format(self.auth())}
r = requests.get(url, headers=headers)
re... | python | def available_metadata(self):
"""
List all scenario metadata indicators available in the connected
data source
"""
url = self.base_url + 'metadata/types'
headers = {'Authorization': 'Bearer {}'.format(self.auth())}
r = requests.get(url, headers=headers)
re... | List all scenario metadata indicators available in the connected
data source | https://github.com/IAMconsortium/pyam/blob/4077929ca6e7be63a0e3ecf882c5f1da97b287bf/pyam/iiasa.py#L87-L95 |
IAMconsortium/pyam | pyam/iiasa.py | Connection.metadata | def metadata(self, default=True):
"""
Metadata of scenarios in the connected data source
Parameter
---------
default : bool, optional, default True
Return *only* the default version of each Scenario.
Any (`model`, `scenario`) without a default version is ... | python | def metadata(self, default=True):
"""
Metadata of scenarios in the connected data source
Parameter
---------
default : bool, optional, default True
Return *only* the default version of each Scenario.
Any (`model`, `scenario`) without a default version is ... | Metadata of scenarios in the connected data source
Parameter
---------
default : bool, optional, default True
Return *only* the default version of each Scenario.
Any (`model`, `scenario`) without a default version is omitted.
If :obj:`False`, return all versi... | https://github.com/IAMconsortium/pyam/blob/4077929ca6e7be63a0e3ecf882c5f1da97b287bf/pyam/iiasa.py#L98-L128 |
IAMconsortium/pyam | pyam/iiasa.py | Connection.variables | def variables(self):
"""All variables in the connected data source"""
url = self.base_url + 'ts'
headers = {'Authorization': 'Bearer {}'.format(self.auth())}
r = requests.get(url, headers=headers)
df = pd.read_json(r.content, orient='records')
return pd.Series(df['variabl... | python | def variables(self):
"""All variables in the connected data source"""
url = self.base_url + 'ts'
headers = {'Authorization': 'Bearer {}'.format(self.auth())}
r = requests.get(url, headers=headers)
df = pd.read_json(r.content, orient='records')
return pd.Series(df['variabl... | All variables in the connected data source | https://github.com/IAMconsortium/pyam/blob/4077929ca6e7be63a0e3ecf882c5f1da97b287bf/pyam/iiasa.py#L141-L147 |
IAMconsortium/pyam | pyam/iiasa.py | Connection.query | def query(self, **kwargs):
"""
Query the data source, subselecting data. Available keyword arguments
include
- model
- scenario
- region
- variable
Example
-------
```
Connection.query(model='MESSAGE', scenario='SSP2*',
... | python | def query(self, **kwargs):
"""
Query the data source, subselecting data. Available keyword arguments
include
- model
- scenario
- region
- variable
Example
-------
```
Connection.query(model='MESSAGE', scenario='SSP2*',
... | Query the data source, subselecting data. Available keyword arguments
include
- model
- scenario
- region
- variable
Example
-------
```
Connection.query(model='MESSAGE', scenario='SSP2*',
variable=['Emissions|CO2', 'Pri... | https://github.com/IAMconsortium/pyam/blob/4077929ca6e7be63a0e3ecf882c5f1da97b287bf/pyam/iiasa.py#L209-L253 |
IAMconsortium/pyam | pyam/statistics.py | format_rows | def format_rows(row, center, fullrange=None, interquartile=None,
custom_format='{:.2f}'):
"""Format a row with `describe()` columns to a concise string"""
if (fullrange or 0) + (interquartile or 0) == 1:
legend = '{} ({})'.format(center, 'max, min' if fullrange is True
... | python | def format_rows(row, center, fullrange=None, interquartile=None,
custom_format='{:.2f}'):
"""Format a row with `describe()` columns to a concise string"""
if (fullrange or 0) + (interquartile or 0) == 1:
legend = '{} ({})'.format(center, 'max, min' if fullrange is True
... | Format a row with `describe()` columns to a concise string | https://github.com/IAMconsortium/pyam/blob/4077929ca6e7be63a0e3ecf882c5f1da97b287bf/pyam/statistics.py#L245-L286 |
IAMconsortium/pyam | pyam/statistics.py | Statistics.add | def add(self, data, header, row=None, subheader=None):
"""Filter `data` by arguments of this SummaryStats instance,
then apply `pd.describe()` and format the statistics
Parameters
----------
data : pd.DataFrame or pd.Series
data for which summary statistics should be... | python | def add(self, data, header, row=None, subheader=None):
"""Filter `data` by arguments of this SummaryStats instance,
then apply `pd.describe()` and format the statistics
Parameters
----------
data : pd.DataFrame or pd.Series
data for which summary statistics should be... | Filter `data` by arguments of this SummaryStats instance,
then apply `pd.describe()` and format the statistics
Parameters
----------
data : pd.DataFrame or pd.Series
data for which summary statistics should be computed
header : str
column name for descrip... | https://github.com/IAMconsortium/pyam/blob/4077929ca6e7be63a0e3ecf882c5f1da97b287bf/pyam/statistics.py#L121-L196 |
IAMconsortium/pyam | pyam/statistics.py | Statistics.reindex | def reindex(self, copy=True):
"""Reindex the summary statistics dataframe"""
ret = deepcopy(self) if copy else self
ret.stats = ret.stats.reindex(index=ret._idx, level=0)
if ret.idx_depth == 2:
ret.stats = ret.stats.reindex(index=ret._sub_idx, level=1)
if ret.rows is... | python | def reindex(self, copy=True):
"""Reindex the summary statistics dataframe"""
ret = deepcopy(self) if copy else self
ret.stats = ret.stats.reindex(index=ret._idx, level=0)
if ret.idx_depth == 2:
ret.stats = ret.stats.reindex(index=ret._sub_idx, level=1)
if ret.rows is... | Reindex the summary statistics dataframe | https://github.com/IAMconsortium/pyam/blob/4077929ca6e7be63a0e3ecf882c5f1da97b287bf/pyam/statistics.py#L198-L213 |
IAMconsortium/pyam | pyam/statistics.py | Statistics.summarize | def summarize(self, center='mean', fullrange=None, interquartile=None,
custom_format='{:.2f}'):
"""Format the compiled statistics to a concise string output
Parameter
---------
center : str, default `mean`
what to return as 'center' of the summary: `mean`, ... | python | def summarize(self, center='mean', fullrange=None, interquartile=None,
custom_format='{:.2f}'):
"""Format the compiled statistics to a concise string output
Parameter
---------
center : str, default `mean`
what to return as 'center' of the summary: `mean`, ... | Format the compiled statistics to a concise string output
Parameter
---------
center : str, default `mean`
what to return as 'center' of the summary: `mean`, `50%`, `median`
fullrange : bool, default None
return full range of data if True or `fullrange`, `interqu... | https://github.com/IAMconsortium/pyam/blob/4077929ca6e7be63a0e3ecf882c5f1da97b287bf/pyam/statistics.py#L215-L240 |
IAMconsortium/pyam | pyam/plotting.py | reset_default_props | def reset_default_props(**kwargs):
"""Reset properties to initial cycle point"""
global _DEFAULT_PROPS
pcycle = plt.rcParams['axes.prop_cycle']
_DEFAULT_PROPS = {
'color': itertools.cycle(_get_standard_colors(**kwargs))
if len(kwargs) > 0 else itertools.cycle([x['color'] for x in pcycle]... | python | def reset_default_props(**kwargs):
"""Reset properties to initial cycle point"""
global _DEFAULT_PROPS
pcycle = plt.rcParams['axes.prop_cycle']
_DEFAULT_PROPS = {
'color': itertools.cycle(_get_standard_colors(**kwargs))
if len(kwargs) > 0 else itertools.cycle([x['color'] for x in pcycle]... | Reset properties to initial cycle point | https://github.com/IAMconsortium/pyam/blob/4077929ca6e7be63a0e3ecf882c5f1da97b287bf/pyam/plotting.py#L75-L84 |
IAMconsortium/pyam | pyam/plotting.py | default_props | def default_props(reset=False, **kwargs):
"""Return current default properties
Parameters
----------
reset : bool
if True, reset properties and return
default: False
"""
global _DEFAULT_PROPS
if _DEFAULT_PROPS is None or reset:
reset_default_props(**kwargs)
... | python | def default_props(reset=False, **kwargs):
"""Return current default properties
Parameters
----------
reset : bool
if True, reset properties and return
default: False
"""
global _DEFAULT_PROPS
if _DEFAULT_PROPS is None or reset:
reset_default_props(**kwargs)
... | Return current default properties
Parameters
----------
reset : bool
if True, reset properties and return
default: False | https://github.com/IAMconsortium/pyam/blob/4077929ca6e7be63a0e3ecf882c5f1da97b287bf/pyam/plotting.py#L87-L99 |
IAMconsortium/pyam | pyam/plotting.py | assign_style_props | def assign_style_props(df, color=None, marker=None, linestyle=None,
cmap=None):
"""Assign the style properties for a plot
Parameters
----------
df : pd.DataFrame
data to be used for style properties
"""
if color is None and cmap is not None:
raise ValueErr... | python | def assign_style_props(df, color=None, marker=None, linestyle=None,
cmap=None):
"""Assign the style properties for a plot
Parameters
----------
df : pd.DataFrame
data to be used for style properties
"""
if color is None and cmap is not None:
raise ValueErr... | Assign the style properties for a plot
Parameters
----------
df : pd.DataFrame
data to be used for style properties | https://github.com/IAMconsortium/pyam/blob/4077929ca6e7be63a0e3ecf882c5f1da97b287bf/pyam/plotting.py#L102-L155 |
IAMconsortium/pyam | pyam/plotting.py | reshape_line_plot | def reshape_line_plot(df, x, y):
"""Reshape data from long form to "line plot form".
Line plot form has x value as the index with one column for each line.
Each column has data points as values and all metadata as column headers.
"""
idx = list(df.columns.drop(y))
if df.duplicated(idx).any():
... | python | def reshape_line_plot(df, x, y):
"""Reshape data from long form to "line plot form".
Line plot form has x value as the index with one column for each line.
Each column has data points as values and all metadata as column headers.
"""
idx = list(df.columns.drop(y))
if df.duplicated(idx).any():
... | Reshape data from long form to "line plot form".
Line plot form has x value as the index with one column for each line.
Each column has data points as values and all metadata as column headers. | https://github.com/IAMconsortium/pyam/blob/4077929ca6e7be63a0e3ecf882c5f1da97b287bf/pyam/plotting.py#L158-L169 |
IAMconsortium/pyam | pyam/plotting.py | reshape_bar_plot | def reshape_bar_plot(df, x, y, bars):
"""Reshape data from long form to "bar plot form".
Bar plot form has x value as the index with one column for bar grouping.
Table values come from y values.
"""
idx = [bars, x]
if df.duplicated(idx).any():
warnings.warn('Duplicated index found.')
... | python | def reshape_bar_plot(df, x, y, bars):
"""Reshape data from long form to "bar plot form".
Bar plot form has x value as the index with one column for bar grouping.
Table values come from y values.
"""
idx = [bars, x]
if df.duplicated(idx).any():
warnings.warn('Duplicated index found.')
... | Reshape data from long form to "bar plot form".
Bar plot form has x value as the index with one column for bar grouping.
Table values come from y values. | https://github.com/IAMconsortium/pyam/blob/4077929ca6e7be63a0e3ecf882c5f1da97b287bf/pyam/plotting.py#L172-L183 |
IAMconsortium/pyam | pyam/plotting.py | read_shapefile | def read_shapefile(fname, region_col=None, **kwargs):
"""Read a shapefile for use in regional plots. Shapefiles must have a
column denoted as "region".
Parameters
----------
fname : string
path to shapefile to be read by geopandas
region_col : string, default None
if provided, r... | python | def read_shapefile(fname, region_col=None, **kwargs):
"""Read a shapefile for use in regional plots. Shapefiles must have a
column denoted as "region".
Parameters
----------
fname : string
path to shapefile to be read by geopandas
region_col : string, default None
if provided, r... | Read a shapefile for use in regional plots. Shapefiles must have a
column denoted as "region".
Parameters
----------
fname : string
path to shapefile to be read by geopandas
region_col : string, default None
if provided, rename a column in the shapefile to "region" | https://github.com/IAMconsortium/pyam/blob/4077929ca6e7be63a0e3ecf882c5f1da97b287bf/pyam/plotting.py#L188-L205 |
IAMconsortium/pyam | pyam/plotting.py | region_plot | def region_plot(df, column='value', ax=None, crs=None, gdf=None,
add_features=True, vmin=None, vmax=None, cmap=None,
cbar=True, legend=False, title=True):
"""Plot data on a map.
Parameters
----------
df : pd.DataFrame
Data to plot as a long-form data frame
co... | python | def region_plot(df, column='value', ax=None, crs=None, gdf=None,
add_features=True, vmin=None, vmax=None, cmap=None,
cbar=True, legend=False, title=True):
"""Plot data on a map.
Parameters
----------
df : pd.DataFrame
Data to plot as a long-form data frame
co... | Plot data on a map.
Parameters
----------
df : pd.DataFrame
Data to plot as a long-form data frame
column : string, optional, default: 'value'
The column to use for plotting values
ax : matplotlib.Axes, optional
crs : cartopy.crs, optional
The crs to plot, PlateCarree is... | https://github.com/IAMconsortium/pyam/blob/4077929ca6e7be63a0e3ecf882c5f1da97b287bf/pyam/plotting.py#L210-L316 |
IAMconsortium/pyam | pyam/plotting.py | pie_plot | def pie_plot(df, value='value', category='variable',
ax=None, legend=False, title=True, cmap=None,
**kwargs):
"""Plot data as a bar chart.
Parameters
----------
df : pd.DataFrame
Data to plot as a long-form data frame
value : string, optional
The column to ... | python | def pie_plot(df, value='value', category='variable',
ax=None, legend=False, title=True, cmap=None,
**kwargs):
"""Plot data as a bar chart.
Parameters
----------
df : pd.DataFrame
Data to plot as a long-form data frame
value : string, optional
The column to ... | Plot data as a bar chart.
Parameters
----------
df : pd.DataFrame
Data to plot as a long-form data frame
value : string, optional
The column to use for data values
default: value
category : string, optional
The column to use for labels
default: variable
a... | https://github.com/IAMconsortium/pyam/blob/4077929ca6e7be63a0e3ecf882c5f1da97b287bf/pyam/plotting.py#L319-L383 |
IAMconsortium/pyam | pyam/plotting.py | stack_plot | def stack_plot(df, x='year', y='value', stack='variable',
ax=None, legend=True, title=True, cmap=None, total=None,
**kwargs):
"""Plot data as a stack chart.
Parameters
----------
df : pd.DataFrame
Data to plot as a long-form data frame
x : string, optional
... | python | def stack_plot(df, x='year', y='value', stack='variable',
ax=None, legend=True, title=True, cmap=None, total=None,
**kwargs):
"""Plot data as a stack chart.
Parameters
----------
df : pd.DataFrame
Data to plot as a long-form data frame
x : string, optional
... | Plot data as a stack chart.
Parameters
----------
df : pd.DataFrame
Data to plot as a long-form data frame
x : string, optional
The column to use for x-axis values
default: year
y : string, optional
The column to use for y-axis values
default: value
stack... | https://github.com/IAMconsortium/pyam/blob/4077929ca6e7be63a0e3ecf882c5f1da97b287bf/pyam/plotting.py#L386-L546 |
IAMconsortium/pyam | pyam/plotting.py | bar_plot | def bar_plot(df, x='year', y='value', bars='variable',
ax=None, orient='v', legend=True, title=True, cmap=None,
**kwargs):
"""Plot data as a bar chart.
Parameters
----------
df : pd.DataFrame
Data to plot as a long-form data frame
x : string, optional
The c... | python | def bar_plot(df, x='year', y='value', bars='variable',
ax=None, orient='v', legend=True, title=True, cmap=None,
**kwargs):
"""Plot data as a bar chart.
Parameters
----------
df : pd.DataFrame
Data to plot as a long-form data frame
x : string, optional
The c... | Plot data as a bar chart.
Parameters
----------
df : pd.DataFrame
Data to plot as a long-form data frame
x : string, optional
The column to use for x-axis values
default: year
y : string, optional
The column to use for y-axis values
default: value
bars: s... | https://github.com/IAMconsortium/pyam/blob/4077929ca6e7be63a0e3ecf882c5f1da97b287bf/pyam/plotting.py#L549-L634 |
IAMconsortium/pyam | pyam/plotting.py | add_net_values_to_bar_plot | def add_net_values_to_bar_plot(axs, color='k'):
"""Add net values next to an existing vertical stacked bar chart
Parameters
----------
axs : matplotlib.Axes or list thereof
color : str, optional, default: black
the color of the bars to add
"""
axs = axs if isinstance(axs, Iterable) ... | python | def add_net_values_to_bar_plot(axs, color='k'):
"""Add net values next to an existing vertical stacked bar chart
Parameters
----------
axs : matplotlib.Axes or list thereof
color : str, optional, default: black
the color of the bars to add
"""
axs = axs if isinstance(axs, Iterable) ... | Add net values next to an existing vertical stacked bar chart
Parameters
----------
axs : matplotlib.Axes or list thereof
color : str, optional, default: black
the color of the bars to add | https://github.com/IAMconsortium/pyam/blob/4077929ca6e7be63a0e3ecf882c5f1da97b287bf/pyam/plotting.py#L650-L664 |
IAMconsortium/pyam | pyam/plotting.py | scatter | def scatter(df, x, y, ax=None, legend=None, title=None,
color=None, marker='o', linestyle=None, cmap=None,
groupby=['model', 'scenario'], with_lines=False, **kwargs):
"""Plot data as a scatter chart.
Parameters
----------
df : pd.DataFrame
Data to plot as a long-form dat... | python | def scatter(df, x, y, ax=None, legend=None, title=None,
color=None, marker='o', linestyle=None, cmap=None,
groupby=['model', 'scenario'], with_lines=False, **kwargs):
"""Plot data as a scatter chart.
Parameters
----------
df : pd.DataFrame
Data to plot as a long-form dat... | Plot data as a scatter chart.
Parameters
----------
df : pd.DataFrame
Data to plot as a long-form data frame
x : str
column to be plotted on the x-axis
y : str
column to be plotted on the y-axis
ax : matplotlib.Axes, optional
legend : bool, optional
Include a... | https://github.com/IAMconsortium/pyam/blob/4077929ca6e7be63a0e3ecf882c5f1da97b287bf/pyam/plotting.py#L667-L760 |
IAMconsortium/pyam | pyam/plotting.py | line_plot | def line_plot(df, x='year', y='value', ax=None, legend=None, title=True,
color=None, marker=None, linestyle=None, cmap=None,
fill_between=None, final_ranges=None,
rm_legend_label=[], **kwargs):
"""Plot data as lines with or without markers.
Parameters
----------
... | python | def line_plot(df, x='year', y='value', ax=None, legend=None, title=True,
color=None, marker=None, linestyle=None, cmap=None,
fill_between=None, final_ranges=None,
rm_legend_label=[], **kwargs):
"""Plot data as lines with or without markers.
Parameters
----------
... | Plot data as lines with or without markers.
Parameters
----------
df : pd.DataFrame
Data to plot as a long-form data frame
x : string, optional
The column to use for x-axis values
default: year
y : string, optional
The column to use for y-axis values
default:... | https://github.com/IAMconsortium/pyam/blob/4077929ca6e7be63a0e3ecf882c5f1da97b287bf/pyam/plotting.py#L763-L948 |
IAMconsortium/pyam | pyam/plotting.py | set_panel_label | def set_panel_label(label, ax=None, x=0.05, y=0.9):
"""Add a panel label to the figure/axes, by default in the top-left corner
Parameters
----------
label : str
text to be added as panel label
ax : matplotlib.Axes, optional
panel to which to add the panel label
x : number, defau... | python | def set_panel_label(label, ax=None, x=0.05, y=0.9):
"""Add a panel label to the figure/axes, by default in the top-left corner
Parameters
----------
label : str
text to be added as panel label
ax : matplotlib.Axes, optional
panel to which to add the panel label
x : number, defau... | Add a panel label to the figure/axes, by default in the top-left corner
Parameters
----------
label : str
text to be added as panel label
ax : matplotlib.Axes, optional
panel to which to add the panel label
x : number, default 0.05
relative location of label to x-axis
y ... | https://github.com/IAMconsortium/pyam/blob/4077929ca6e7be63a0e3ecf882c5f1da97b287bf/pyam/plotting.py#L964-L984 |
IAMconsortium/pyam | pyam/logger.py | logger | def logger():
"""Access global logger"""
global _LOGGER
if _LOGGER is None:
logging.basicConfig()
_LOGGER = logging.getLogger()
_LOGGER.setLevel('INFO')
return _LOGGER | python | def logger():
"""Access global logger"""
global _LOGGER
if _LOGGER is None:
logging.basicConfig()
_LOGGER = logging.getLogger()
_LOGGER.setLevel('INFO')
return _LOGGER | Access global logger | https://github.com/IAMconsortium/pyam/blob/4077929ca6e7be63a0e3ecf882c5f1da97b287bf/pyam/logger.py#L7-L14 |
linode/linode_api4-python | linode_api4/objects/nodebalancer.py | NodeBalancerConfig.nodes | def nodes(self):
"""
This is a special derived_class relationship because NodeBalancerNode is the
only api object that requires two parent_ids
"""
if not hasattr(self, '_nodes'):
base_url = "{}/{}".format(NodeBalancerConfig.api_endpoint, NodeBalancerNode.derived_url_p... | python | def nodes(self):
"""
This is a special derived_class relationship because NodeBalancerNode is the
only api object that requires two parent_ids
"""
if not hasattr(self, '_nodes'):
base_url = "{}/{}".format(NodeBalancerConfig.api_endpoint, NodeBalancerNode.derived_url_p... | This is a special derived_class relationship because NodeBalancerNode is the
only api object that requires two parent_ids | https://github.com/linode/linode_api4-python/blob/1dd7318d2aed014c746d48c7957464c57af883ca/linode_api4/objects/nodebalancer.py#L73-L84 |
linode/linode_api4-python | linode_api4/objects/nodebalancer.py | NodeBalancerConfig.load_ssl_data | def load_ssl_data(self, cert_file, key_file):
"""
A convenience method that loads a cert and a key from files and sets them
on this object. This can make enabling ssl easier (instead of you needing
to load the files yourself).
This does *not* change protocol/port for you, or sa... | python | def load_ssl_data(self, cert_file, key_file):
"""
A convenience method that loads a cert and a key from files and sets them
on this object. This can make enabling ssl easier (instead of you needing
to load the files yourself).
This does *not* change protocol/port for you, or sa... | A convenience method that loads a cert and a key from files and sets them
on this object. This can make enabling ssl easier (instead of you needing
to load the files yourself).
This does *not* change protocol/port for you, or save anything. Once this
is called, you must still call `sa... | https://github.com/linode/linode_api4-python/blob/1dd7318d2aed014c746d48c7957464c57af883ca/linode_api4/objects/nodebalancer.py#L103-L126 |
linode/linode_api4-python | linode_api4/common.py | load_and_validate_keys | def load_and_validate_keys(authorized_keys):
"""
Loads authorized_keys as taken by :any:`instance_create`,
:any:`disk_create` or :any:`rebuild`, and loads in any keys from any files
provided.
:param authorized_keys: A list of keys or paths to keys, or a single key
:returns: A list of raw keys
... | python | def load_and_validate_keys(authorized_keys):
"""
Loads authorized_keys as taken by :any:`instance_create`,
:any:`disk_create` or :any:`rebuild`, and loads in any keys from any files
provided.
:param authorized_keys: A list of keys or paths to keys, or a single key
:returns: A list of raw keys
... | Loads authorized_keys as taken by :any:`instance_create`,
:any:`disk_create` or :any:`rebuild`, and loads in any keys from any files
provided.
:param authorized_keys: A list of keys or paths to keys, or a single key
:returns: A list of raw keys
:raises: ValueError if keys in authorized_keys don't ... | https://github.com/linode/linode_api4-python/blob/1dd7318d2aed014c746d48c7957464c57af883ca/linode_api4/common.py#L10-L45 |
linode/linode_api4-python | linode_api4/objects/volume.py | Volume.attach | def attach(self, to_linode, config=None):
"""
Attaches this Volume to the given Linode
"""
result = self._client.post('{}/attach'.format(Volume.api_endpoint), model=self,
data={
"linode_id": to_linode.id if issubclass(type(to_linode), Base) else to_lin... | python | def attach(self, to_linode, config=None):
"""
Attaches this Volume to the given Linode
"""
result = self._client.post('{}/attach'.format(Volume.api_endpoint), model=self,
data={
"linode_id": to_linode.id if issubclass(type(to_linode), Base) else to_lin... | Attaches this Volume to the given Linode | https://github.com/linode/linode_api4-python/blob/1dd7318d2aed014c746d48c7957464c57af883ca/linode_api4/objects/volume.py#L22-L36 |
linode/linode_api4-python | linode_api4/objects/volume.py | Volume.detach | def detach(self):
"""
Detaches this Volume if it is attached
"""
self._client.post('{}/detach'.format(Volume.api_endpoint), model=self)
return True | python | def detach(self):
"""
Detaches this Volume if it is attached
"""
self._client.post('{}/detach'.format(Volume.api_endpoint), model=self)
return True | Detaches this Volume if it is attached | https://github.com/linode/linode_api4-python/blob/1dd7318d2aed014c746d48c7957464c57af883ca/linode_api4/objects/volume.py#L38-L44 |
linode/linode_api4-python | linode_api4/objects/volume.py | Volume.resize | def resize(self, size):
"""
Resizes this Volume
"""
result = self._client.post('{}/resize'.format(Volume.api_endpoint, model=self,
data={ "size": size }))
self._populate(result.json)
return True | python | def resize(self, size):
"""
Resizes this Volume
"""
result = self._client.post('{}/resize'.format(Volume.api_endpoint, model=self,
data={ "size": size }))
self._populate(result.json)
return True | Resizes this Volume | https://github.com/linode/linode_api4-python/blob/1dd7318d2aed014c746d48c7957464c57af883ca/linode_api4/objects/volume.py#L46-L55 |
linode/linode_api4-python | linode_api4/objects/volume.py | Volume.clone | def clone(self, label):
"""
Clones this volume to a new volume in the same region with the given label
:param label: The label for the new volume.
:returns: The new volume object.
"""
result = self._client.post('{}/clone'.format(Volume.api_endpoint),
mod... | python | def clone(self, label):
"""
Clones this volume to a new volume in the same region with the given label
:param label: The label for the new volume.
:returns: The new volume object.
"""
result = self._client.post('{}/clone'.format(Volume.api_endpoint),
mod... | Clones this volume to a new volume in the same region with the given label
:param label: The label for the new volume.
:returns: The new volume object. | https://github.com/linode/linode_api4-python/blob/1dd7318d2aed014c746d48c7957464c57af883ca/linode_api4/objects/volume.py#L57-L71 |
linode/linode_api4-python | linode_api4/objects/tag.py | Tag._get_raw_objects | def _get_raw_objects(self):
"""
Helper function to populate the first page of raw objects for this tag.
This has the side effect of creating the ``_raw_objects`` attribute of
this object.
"""
if not hasattr(self, '_raw_objects'):
result = self._client.get(type... | python | def _get_raw_objects(self):
"""
Helper function to populate the first page of raw objects for this tag.
This has the side effect of creating the ``_raw_objects`` attribute of
this object.
"""
if not hasattr(self, '_raw_objects'):
result = self._client.get(type... | Helper function to populate the first page of raw objects for this tag.
This has the side effect of creating the ``_raw_objects`` attribute of
this object. | https://github.com/linode/linode_api4-python/blob/1dd7318d2aed014c746d48c7957464c57af883ca/linode_api4/objects/tag.py#L32-L45 |
linode/linode_api4-python | linode_api4/objects/tag.py | Tag.objects | def objects(self):
"""
Returns a list of objects with this Tag. This list may contain any
taggable object type.
"""
data = self._get_raw_objects()
return PaginatedList.make_paginated_list(data, self._client, TaggedObjectProxy,
... | python | def objects(self):
"""
Returns a list of objects with this Tag. This list may contain any
taggable object type.
"""
data = self._get_raw_objects()
return PaginatedList.make_paginated_list(data, self._client, TaggedObjectProxy,
... | Returns a list of objects with this Tag. This list may contain any
taggable object type. | https://github.com/linode/linode_api4-python/blob/1dd7318d2aed014c746d48c7957464c57af883ca/linode_api4/objects/tag.py#L60-L68 |
linode/linode_api4-python | linode_api4/objects/tag.py | TaggedObjectProxy.make_instance | def make_instance(cls, id, client, parent_id=None, json=None):
"""
Overrides Base's ``make_instance`` to allow dynamic creation of objects
based on the defined type in the response json.
:param cls: The class this was called on
:param id: The id of the instance to create
... | python | def make_instance(cls, id, client, parent_id=None, json=None):
"""
Overrides Base's ``make_instance`` to allow dynamic creation of objects
based on the defined type in the response json.
:param cls: The class this was called on
:param id: The id of the instance to create
... | Overrides Base's ``make_instance`` to allow dynamic creation of objects
based on the defined type in the response json.
:param cls: The class this was called on
:param id: The id of the instance to create
:param client: The client to use for this instance
:param parent_id: The p... | https://github.com/linode/linode_api4-python/blob/1dd7318d2aed014c746d48c7957464c57af883ca/linode_api4/objects/tag.py#L89-L113 |
linode/linode_api4-python | linode_api4/objects/linode.py | Disk.resize | def resize(self, new_size):
"""
Resizes this disk. The Linode Instance this disk belongs to must have
sufficient space available to accommodate the new size, and must be
offline.
**NOTE** If resizing a disk down, the filesystem on the disk must still
fit on the new disk... | python | def resize(self, new_size):
"""
Resizes this disk. The Linode Instance this disk belongs to must have
sufficient space available to accommodate the new size, and must be
offline.
**NOTE** If resizing a disk down, the filesystem on the disk must still
fit on the new disk... | Resizes this disk. The Linode Instance this disk belongs to must have
sufficient space available to accommodate the new size, and must be
offline.
**NOTE** If resizing a disk down, the filesystem on the disk must still
fit on the new disk size. You may need to resize the filesystem on... | https://github.com/linode/linode_api4-python/blob/1dd7318d2aed014c746d48c7957464c57af883ca/linode_api4/objects/linode.py#L98-L116 |
linode/linode_api4-python | linode_api4/objects/linode.py | Config._populate | def _populate(self, json):
"""
Map devices more nicely while populating.
"""
from .volume import Volume
DerivedBase._populate(self, json)
devices = {}
for device_index, device in json['devices'].items():
if not device:
devices[device_... | python | def _populate(self, json):
"""
Map devices more nicely while populating.
"""
from .volume import Volume
DerivedBase._populate(self, json)
devices = {}
for device_index, device in json['devices'].items():
if not device:
devices[device_... | Map devices more nicely while populating. | https://github.com/linode/linode_api4-python/blob/1dd7318d2aed014c746d48c7957464c57af883ca/linode_api4/objects/linode.py#L172-L195 |
linode/linode_api4-python | linode_api4/objects/linode.py | Instance.ips | def ips(self):
"""
The ips related collection is not normalized like the others, so we have to
make an ad-hoc object to return for its response
"""
if not hasattr(self, '_ips'):
result = self._client.get("{}/ips".format(Instance.api_endpoint), model=self)
... | python | def ips(self):
"""
The ips related collection is not normalized like the others, so we have to
make an ad-hoc object to return for its response
"""
if not hasattr(self, '_ips'):
result = self._client.get("{}/ips".format(Instance.api_endpoint), model=self)
... | The ips related collection is not normalized like the others, so we have to
make an ad-hoc object to return for its response | https://github.com/linode/linode_api4-python/blob/1dd7318d2aed014c746d48c7957464c57af883ca/linode_api4/objects/linode.py#L222-L272 |
linode/linode_api4-python | linode_api4/objects/linode.py | Instance.available_backups | def available_backups(self):
"""
The backups response contains what backups are available to be restored.
"""
if not hasattr(self, '_avail_backups'):
result = self._client.get("{}/backups".format(Instance.api_endpoint), model=self)
if not 'automatic' in result:
... | python | def available_backups(self):
"""
The backups response contains what backups are available to be restored.
"""
if not hasattr(self, '_avail_backups'):
result = self._client.get("{}/backups".format(Instance.api_endpoint), model=self)
if not 'automatic' in result:
... | The backups response contains what backups are available to be restored. | https://github.com/linode/linode_api4-python/blob/1dd7318d2aed014c746d48c7957464c57af883ca/linode_api4/objects/linode.py#L275-L308 |
linode/linode_api4-python | linode_api4/objects/linode.py | Instance.invalidate | def invalidate(self):
""" Clear out cached properties """
if hasattr(self, '_avail_backups'):
del self._avail_backups
if hasattr(self, '_ips'):
del self._ips
Base.invalidate(self) | python | def invalidate(self):
""" Clear out cached properties """
if hasattr(self, '_avail_backups'):
del self._avail_backups
if hasattr(self, '_ips'):
del self._ips
Base.invalidate(self) | Clear out cached properties | https://github.com/linode/linode_api4-python/blob/1dd7318d2aed014c746d48c7957464c57af883ca/linode_api4/objects/linode.py#L321-L328 |
linode/linode_api4-python | linode_api4/objects/linode.py | Instance.config_create | def config_create(self, kernel=None, label=None, devices=[], disks=[],
volumes=[], **kwargs):
"""
Creates a Linode Config with the given attributes.
:param kernel: The kernel to boot with.
:param label: The config label
:param disks: The list of disks, starting at sd... | python | def config_create(self, kernel=None, label=None, devices=[], disks=[],
volumes=[], **kwargs):
"""
Creates a Linode Config with the given attributes.
:param kernel: The kernel to boot with.
:param label: The config label
:param disks: The list of disks, starting at sd... | Creates a Linode Config with the given attributes.
:param kernel: The kernel to boot with.
:param label: The config label
:param disks: The list of disks, starting at sda, to map to this config.
:param volumes: The volumes, starting after the last disk, to map to this
config... | https://github.com/linode/linode_api4-python/blob/1dd7318d2aed014c746d48c7957464c57af883ca/linode_api4/objects/linode.py#L378-L456 |
linode/linode_api4-python | linode_api4/objects/linode.py | Instance.enable_backups | def enable_backups(self):
"""
Enable Backups for this Instance. When enabled, we will automatically
backup your Instance's data so that it can be restored at a later date.
For more information on Instance's Backups service and pricing, see our
`Backups Page`_
.. _Backup... | python | def enable_backups(self):
"""
Enable Backups for this Instance. When enabled, we will automatically
backup your Instance's data so that it can be restored at a later date.
For more information on Instance's Backups service and pricing, see our
`Backups Page`_
.. _Backup... | Enable Backups for this Instance. When enabled, we will automatically
backup your Instance's data so that it can be restored at a later date.
For more information on Instance's Backups service and pricing, see our
`Backups Page`_
.. _Backups Page: https://www.linode.com/backups | https://github.com/linode/linode_api4-python/blob/1dd7318d2aed014c746d48c7957464c57af883ca/linode_api4/objects/linode.py#L502-L513 |
linode/linode_api4-python | linode_api4/objects/linode.py | Instance.ip_allocate | def ip_allocate(self, public=False):
"""
Allocates a new :any:`IPAddress` for this Instance. Additional public
IPs require justification, and you may need to open a :any:`SupportTicket`
before you can add one. You may only have, at most, one private IP per
Instance.
:p... | python | def ip_allocate(self, public=False):
"""
Allocates a new :any:`IPAddress` for this Instance. Additional public
IPs require justification, and you may need to open a :any:`SupportTicket`
before you can add one. You may only have, at most, one private IP per
Instance.
:p... | Allocates a new :any:`IPAddress` for this Instance. Additional public
IPs require justification, and you may need to open a :any:`SupportTicket`
before you can add one. You may only have, at most, one private IP per
Instance.
:param public: If the new IP should be public or private. ... | https://github.com/linode/linode_api4-python/blob/1dd7318d2aed014c746d48c7957464c57af883ca/linode_api4/objects/linode.py#L539-L566 |
linode/linode_api4-python | linode_api4/objects/linode.py | Instance.rebuild | def rebuild(self, image, root_pass=None, authorized_keys=None, **kwargs):
"""
Rebuilding an Instance deletes all existing Disks and Configs and deploys
a new :any:`Image` to it. This can be used to reset an existing
Instance or to install an Image on an empty Instance.
:param i... | python | def rebuild(self, image, root_pass=None, authorized_keys=None, **kwargs):
"""
Rebuilding an Instance deletes all existing Disks and Configs and deploys
a new :any:`Image` to it. This can be used to reset an existing
Instance or to install an Image on an empty Instance.
:param i... | Rebuilding an Instance deletes all existing Disks and Configs and deploys
a new :any:`Image` to it. This can be used to reset an existing
Instance or to install an Image on an empty Instance.
:param image: The Image to deploy to this Instance
:type image: str or Image
:param ro... | https://github.com/linode/linode_api4-python/blob/1dd7318d2aed014c746d48c7957464c57af883ca/linode_api4/objects/linode.py#L568-L614 |
linode/linode_api4-python | linode_api4/objects/linode.py | Instance.mutate | def mutate(self):
"""
Upgrades this Instance to the latest generation type
"""
self._client.post('{}/mutate'.format(Instance.api_endpoint), model=self)
return True | python | def mutate(self):
"""
Upgrades this Instance to the latest generation type
"""
self._client.post('{}/mutate'.format(Instance.api_endpoint), model=self)
return True | Upgrades this Instance to the latest generation type | https://github.com/linode/linode_api4-python/blob/1dd7318d2aed014c746d48c7957464c57af883ca/linode_api4/objects/linode.py#L635-L641 |
linode/linode_api4-python | linode_api4/objects/linode.py | Instance.initiate_migration | def initiate_migration(self):
"""
Initiates a pending migration that is already scheduled for this Linode
Instance
"""
self._client.post('{}/migrate'.format(Instance.api_endpoint), model=self) | python | def initiate_migration(self):
"""
Initiates a pending migration that is already scheduled for this Linode
Instance
"""
self._client.post('{}/migrate'.format(Instance.api_endpoint), model=self) | Initiates a pending migration that is already scheduled for this Linode
Instance | https://github.com/linode/linode_api4-python/blob/1dd7318d2aed014c746d48c7957464c57af883ca/linode_api4/objects/linode.py#L643-L648 |
linode/linode_api4-python | linode_api4/objects/linode.py | Instance.clone | def clone(self, to_linode=None, region=None, service=None, configs=[], disks=[],
label=None, group=None, with_backups=None):
""" Clones this linode into a new linode or into a new linode in the given region """
if to_linode and region:
raise ValueError('You may only specify one o... | python | def clone(self, to_linode=None, region=None, service=None, configs=[], disks=[],
label=None, group=None, with_backups=None):
""" Clones this linode into a new linode or into a new linode in the given region """
if to_linode and region:
raise ValueError('You may only specify one o... | Clones this linode into a new linode or into a new linode in the given region | https://github.com/linode/linode_api4-python/blob/1dd7318d2aed014c746d48c7957464c57af883ca/linode_api4/objects/linode.py#L650-L684 |
linode/linode_api4-python | linode_api4/objects/linode.py | Instance.stats | def stats(self):
"""
Returns the JSON stats for this Instance
"""
# TODO - this would be nicer if we formatted the stats
return self._client.get('{}/stats'.format(Instance.api_endpoint), model=self) | python | def stats(self):
"""
Returns the JSON stats for this Instance
"""
# TODO - this would be nicer if we formatted the stats
return self._client.get('{}/stats'.format(Instance.api_endpoint), model=self) | Returns the JSON stats for this Instance | https://github.com/linode/linode_api4-python/blob/1dd7318d2aed014c746d48c7957464c57af883ca/linode_api4/objects/linode.py#L687-L692 |
linode/linode_api4-python | linode_api4/objects/linode.py | Instance.stats_for | def stats_for(self, dt):
"""
Returns stats for the month containing the given datetime
"""
# TODO - this would be nicer if we formatted the stats
if not isinstance(dt, datetime):
raise TypeError('stats_for requires a datetime object!')
return self._client.get(... | python | def stats_for(self, dt):
"""
Returns stats for the month containing the given datetime
"""
# TODO - this would be nicer if we formatted the stats
if not isinstance(dt, datetime):
raise TypeError('stats_for requires a datetime object!')
return self._client.get(... | Returns stats for the month containing the given datetime | https://github.com/linode/linode_api4-python/blob/1dd7318d2aed014c746d48c7957464c57af883ca/linode_api4/objects/linode.py#L694-L701 |
linode/linode_api4-python | linode_api4/objects/linode.py | StackScript._populate | def _populate(self, json):
"""
Override the populate method to map user_defined_fields to
fancy values
"""
Base._populate(self, json)
mapped_udfs = []
for udf in self.user_defined_fields:
t = UserDefinedFieldType.text
choices = None
... | python | def _populate(self, json):
"""
Override the populate method to map user_defined_fields to
fancy values
"""
Base._populate(self, json)
mapped_udfs = []
for udf in self.user_defined_fields:
t = UserDefinedFieldType.text
choices = None
... | Override the populate method to map user_defined_fields to
fancy values | https://github.com/linode/linode_api4-python/blob/1dd7318d2aed014c746d48c7957464c57af883ca/linode_api4/objects/linode.py#L738-L763 |
linode/linode_api4-python | linode_api4/objects/account.py | InvoiceItem._populate | def _populate(self, json):
"""
Allows population of "from_date" from the returned "from" attribute which
is a reserved word in python. Also populates "to_date" to be complete.
"""
super(InvoiceItem, self)._populate(json)
self.from_date = datetime.strptime(json['from'], ... | python | def _populate(self, json):
"""
Allows population of "from_date" from the returned "from" attribute which
is a reserved word in python. Also populates "to_date" to be complete.
"""
super(InvoiceItem, self)._populate(json)
self.from_date = datetime.strptime(json['from'], ... | Allows population of "from_date" from the returned "from" attribute which
is a reserved word in python. Also populates "to_date" to be complete. | https://github.com/linode/linode_api4-python/blob/1dd7318d2aed014c746d48c7957464c57af883ca/linode_api4/objects/account.py#L128-L136 |
linode/linode_api4-python | linode_api4/objects/account.py | OAuthClient.reset_secret | def reset_secret(self):
"""
Resets the client secret for this client.
"""
result = self._client.post("{}/reset_secret".format(OAuthClient.api_endpoint), model=self)
if not 'id' in result:
raise UnexpectedResponseError('Unexpected response when resetting secret!', jso... | python | def reset_secret(self):
"""
Resets the client secret for this client.
"""
result = self._client.post("{}/reset_secret".format(OAuthClient.api_endpoint), model=self)
if not 'id' in result:
raise UnexpectedResponseError('Unexpected response when resetting secret!', jso... | Resets the client secret for this client. | https://github.com/linode/linode_api4-python/blob/1dd7318d2aed014c746d48c7957464c57af883ca/linode_api4/objects/account.py#L163-L173 |
linode/linode_api4-python | linode_api4/objects/account.py | OAuthClient.thumbnail | def thumbnail(self, dump_to=None):
"""
This returns binary data that represents a 128x128 image.
If dump_to is given, attempts to write the image to a file
at the given location.
"""
headers = {
"Authorization": "token {}".format(self._client.token)
}
... | python | def thumbnail(self, dump_to=None):
"""
This returns binary data that represents a 128x128 image.
If dump_to is given, attempts to write the image to a file
at the given location.
"""
headers = {
"Authorization": "token {}".format(self._client.token)
}
... | This returns binary data that represents a 128x128 image.
If dump_to is given, attempts to write the image to a file
at the given location. | https://github.com/linode/linode_api4-python/blob/1dd7318d2aed014c746d48c7957464c57af883ca/linode_api4/objects/account.py#L175-L195 |
linode/linode_api4-python | linode_api4/objects/account.py | OAuthClient.set_thumbnail | def set_thumbnail(self, thumbnail):
"""
Sets the thumbnail for this OAuth Client. If thumbnail is bytes,
uploads it as a png. Otherwise, assumes thumbnail is a path to the
thumbnail and reads it in as bytes before uploading.
"""
headers = {
"Authorization": ... | python | def set_thumbnail(self, thumbnail):
"""
Sets the thumbnail for this OAuth Client. If thumbnail is bytes,
uploads it as a png. Otherwise, assumes thumbnail is a path to the
thumbnail and reads it in as bytes before uploading.
"""
headers = {
"Authorization": ... | Sets the thumbnail for this OAuth Client. If thumbnail is bytes,
uploads it as a png. Otherwise, assumes thumbnail is a path to the
thumbnail and reads it in as bytes before uploading. | https://github.com/linode/linode_api4-python/blob/1dd7318d2aed014c746d48c7957464c57af883ca/linode_api4/objects/account.py#L197-L224 |
linode/linode_api4-python | linode_api4/objects/account.py | User.grants | def grants(self):
"""
Retrieves the grants for this user. If the user is unrestricted, this
will result in an ApiError. This is smart, and will only fetch from the
api once unless the object is invalidated.
:returns: The grants for this user.
:rtype: linode.objects.acc... | python | def grants(self):
"""
Retrieves the grants for this user. If the user is unrestricted, this
will result in an ApiError. This is smart, and will only fetch from the
api once unless the object is invalidated.
:returns: The grants for this user.
:rtype: linode.objects.acc... | Retrieves the grants for this user. If the user is unrestricted, this
will result in an ApiError. This is smart, and will only fetch from the
api once unless the object is invalidated.
:returns: The grants for this user.
:rtype: linode.objects.account.UserGrants | https://github.com/linode/linode_api4-python/blob/1dd7318d2aed014c746d48c7957464c57af883ca/linode_api4/objects/account.py#L248-L264 |
linode/linode_api4-python | linode_api4/objects/account.py | Grant.entity | def entity(self):
"""
Returns the object this grant is for. The objects type depends on the
type of object this grant is applied to, and the object returned is
not populated (accessing its attributes will trigger an api request).
:returns: This grant's entity
:rtype: Li... | python | def entity(self):
"""
Returns the object this grant is for. The objects type depends on the
type of object this grant is applied to, and the object returned is
not populated (accessing its attributes will trigger an api request).
:returns: This grant's entity
:rtype: Li... | Returns the object this grant is for. The objects type depends on the
type of object this grant is applied to, and the object returned is
not populated (accessing its attributes will trigger an api request).
:returns: This grant's entity
:rtype: Linode, NodeBalancer, Domain, StackScrip... | https://github.com/linode/linode_api4-python/blob/1dd7318d2aed014c746d48c7957464c57af883ca/linode_api4/objects/account.py#L302-L314 |
linode/linode_api4-python | linode_api4/paginated_list.py | PaginatedList.make_list | def make_list(json_arr, client, cls, parent_id=None):
"""
Returns a list of Populated objects of the given class type. This
should not be called outside of the :any:`LinodeClient` class.
:param json_arr: The array of JSON data to make into a list
:param client: The LinodeClient... | python | def make_list(json_arr, client, cls, parent_id=None):
"""
Returns a list of Populated objects of the given class type. This
should not be called outside of the :any:`LinodeClient` class.
:param json_arr: The array of JSON data to make into a list
:param client: The LinodeClient... | Returns a list of Populated objects of the given class type. This
should not be called outside of the :any:`LinodeClient` class.
:param json_arr: The array of JSON data to make into a list
:param client: The LinodeClient to pass to new objects
:param parent_id: The parent id for derive... | https://github.com/linode/linode_api4-python/blob/1dd7318d2aed014c746d48c7957464c57af883ca/linode_api4/paginated_list.py#L169-L194 |
linode/linode_api4-python | linode_api4/paginated_list.py | PaginatedList.make_paginated_list | def make_paginated_list(json, client, cls, parent_id=None, page_url=None,
filters=None):
"""
Returns a PaginatedList populated with the first page of data provided,
and the ability to load additional pages. This should not be called
outside of the :any:`LinodeClient` class.
... | python | def make_paginated_list(json, client, cls, parent_id=None, page_url=None,
filters=None):
"""
Returns a PaginatedList populated with the first page of data provided,
and the ability to load additional pages. This should not be called
outside of the :any:`LinodeClient` class.
... | Returns a PaginatedList populated with the first page of data provided,
and the ability to load additional pages. This should not be called
outside of the :any:`LinodeClient` class.
:param json: The JSON list to use as the first page
:param client: A LinodeClient to use to load additio... | https://github.com/linode/linode_api4-python/blob/1dd7318d2aed014c746d48c7957464c57af883ca/linode_api4/paginated_list.py#L197-L219 |
linode/linode_api4-python | linode_api4/objects/base.py | Base.save | def save(self):
"""
Send this object's mutable values to the server in a PUT request
"""
resp = self._client.put(type(self).api_endpoint, model=self,
data=self._serialize())
if 'error' in resp:
return False
return True | python | def save(self):
"""
Send this object's mutable values to the server in a PUT request
"""
resp = self._client.put(type(self).api_endpoint, model=self,
data=self._serialize())
if 'error' in resp:
return False
return True | Send this object's mutable values to the server in a PUT request | https://github.com/linode/linode_api4-python/blob/1dd7318d2aed014c746d48c7957464c57af883ca/linode_api4/objects/base.py#L150-L159 |
linode/linode_api4-python | linode_api4/objects/base.py | Base.delete | def delete(self):
"""
Sends a DELETE request for this object
"""
resp = self._client.delete(type(self).api_endpoint, model=self)
if 'error' in resp:
return False
self.invalidate()
return True | python | def delete(self):
"""
Sends a DELETE request for this object
"""
resp = self._client.delete(type(self).api_endpoint, model=self)
if 'error' in resp:
return False
self.invalidate()
return True | Sends a DELETE request for this object | https://github.com/linode/linode_api4-python/blob/1dd7318d2aed014c746d48c7957464c57af883ca/linode_api4/objects/base.py#L161-L170 |
linode/linode_api4-python | linode_api4/objects/base.py | Base.invalidate | def invalidate(self):
"""
Invalidates all non-identifier Properties this object has locally,
causing the next access to re-fetch them from the server
"""
for key in [k for k in type(self).properties.keys()
if not type(self).properties[k].identifier]:
s... | python | def invalidate(self):
"""
Invalidates all non-identifier Properties this object has locally,
causing the next access to re-fetch them from the server
"""
for key in [k for k in type(self).properties.keys()
if not type(self).properties[k].identifier]:
s... | Invalidates all non-identifier Properties this object has locally,
causing the next access to re-fetch them from the server | https://github.com/linode/linode_api4-python/blob/1dd7318d2aed014c746d48c7957464c57af883ca/linode_api4/objects/base.py#L172-L181 |
linode/linode_api4-python | linode_api4/objects/base.py | Base._serialize | def _serialize(self):
"""
A helper method to build a dict of all mutable Properties of
this object
"""
result = { a: getattr(self, a) for a in type(self).properties
if type(self).properties[a].mutable }
for k, v in result.items():
if isinstance(v,... | python | def _serialize(self):
"""
A helper method to build a dict of all mutable Properties of
this object
"""
result = { a: getattr(self, a) for a in type(self).properties
if type(self).properties[a].mutable }
for k, v in result.items():
if isinstance(v,... | A helper method to build a dict of all mutable Properties of
this object | https://github.com/linode/linode_api4-python/blob/1dd7318d2aed014c746d48c7957464c57af883ca/linode_api4/objects/base.py#L183-L195 |
linode/linode_api4-python | linode_api4/objects/base.py | Base._api_get | def _api_get(self):
"""
A helper method to GET this object from the server
"""
json = self._client.get(type(self).api_endpoint, model=self)
self._populate(json) | python | def _api_get(self):
"""
A helper method to GET this object from the server
"""
json = self._client.get(type(self).api_endpoint, model=self)
self._populate(json) | A helper method to GET this object from the server | https://github.com/linode/linode_api4-python/blob/1dd7318d2aed014c746d48c7957464c57af883ca/linode_api4/objects/base.py#L197-L202 |
linode/linode_api4-python | linode_api4/objects/base.py | Base._populate | def _populate(self, json):
"""
A helper method that, given a JSON object representing this object,
assigns values based on the properties dict and the attributes of
its Properties.
"""
if not json:
return
# hide the raw JSON away in case someone needs... | python | def _populate(self, json):
"""
A helper method that, given a JSON object representing this object,
assigns values based on the properties dict and the attributes of
its Properties.
"""
if not json:
return
# hide the raw JSON away in case someone needs... | A helper method that, given a JSON object representing this object,
assigns values based on the properties dict and the attributes of
its Properties. | https://github.com/linode/linode_api4-python/blob/1dd7318d2aed014c746d48c7957464c57af883ca/linode_api4/objects/base.py#L204-L265 |
linode/linode_api4-python | linode_api4/objects/base.py | Base.make | def make(id, client, cls, parent_id=None, json=None):
"""
Makes an api object based on an id and class.
:param id: The id of the object to create
:param client: The LinodeClient to give the new object
:param cls: The class type to instantiate
:param parent_id: The parent... | python | def make(id, client, cls, parent_id=None, json=None):
"""
Makes an api object based on an id and class.
:param id: The id of the object to create
:param client: The LinodeClient to give the new object
:param cls: The class type to instantiate
:param parent_id: The parent... | Makes an api object based on an id and class.
:param id: The id of the object to create
:param client: The LinodeClient to give the new object
:param cls: The class type to instantiate
:param parent_id: The parent id for derived classes
:param json: The JSON to use to populate t... | https://github.com/linode/linode_api4-python/blob/1dd7318d2aed014c746d48c7957464c57af883ca/linode_api4/objects/base.py#L283-L300 |
linode/linode_api4-python | linode_api4/objects/base.py | Base.make_instance | def make_instance(cls, id, client, parent_id=None, json=None):
"""
Makes an instance of the class this is called on and returns it.
The intended usage is:
instance = Linode.make_instance(123, client, json=response)
:param cls: The class this was called on.
:param id: ... | python | def make_instance(cls, id, client, parent_id=None, json=None):
"""
Makes an instance of the class this is called on and returns it.
The intended usage is:
instance = Linode.make_instance(123, client, json=response)
:param cls: The class this was called on.
:param id: ... | Makes an instance of the class this is called on and returns it.
The intended usage is:
instance = Linode.make_instance(123, client, json=response)
:param cls: The class this was called on.
:param id: The id of the instance to create
:param client: The client to use for this ... | https://github.com/linode/linode_api4-python/blob/1dd7318d2aed014c746d48c7957464c57af883ca/linode_api4/objects/base.py#L303-L318 |
linode/linode_api4-python | linode_api4/objects/filtering.py | or_ | def or_(a, b):
"""
Combines two :any:`Filters<Filter>` with an "or" operation, matching
any results that match any of the given filters.
:param a: The first filter to consider.
:type a: Filter
:param b: The second filter to consider.
:type b: Filter
:returns: A filter that matches eith... | python | def or_(a, b):
"""
Combines two :any:`Filters<Filter>` with an "or" operation, matching
any results that match any of the given filters.
:param a: The first filter to consider.
:type a: Filter
:param b: The second filter to consider.
:type b: Filter
:returns: A filter that matches eith... | Combines two :any:`Filters<Filter>` with an "or" operation, matching
any results that match any of the given filters.
:param a: The first filter to consider.
:type a: Filter
:param b: The second filter to consider.
:type b: Filter
:returns: A filter that matches either a or b
:rtype: Filt... | https://github.com/linode/linode_api4-python/blob/1dd7318d2aed014c746d48c7957464c57af883ca/linode_api4/objects/filtering.py#L45-L60 |
linode/linode_api4-python | linode_api4/objects/networking.py | IPAddress.to | def to(self, linode):
"""
This is a helper method for ip-assign, and should not be used outside
of that context. It's used to cleanly build an IP Assign request with
pretty python syntax.
"""
from .linode import Instance
if not isinstance(linode, Instance):
... | python | def to(self, linode):
"""
This is a helper method for ip-assign, and should not be used outside
of that context. It's used to cleanly build an IP Assign request with
pretty python syntax.
"""
from .linode import Instance
if not isinstance(linode, Instance):
... | This is a helper method for ip-assign, and should not be used outside
of that context. It's used to cleanly build an IP Assign request with
pretty python syntax. | https://github.com/linode/linode_api4-python/blob/1dd7318d2aed014c746d48c7957464c57af883ca/linode_api4/objects/networking.py#L49-L58 |
linode/linode_api4-python | linode_api4/linode_client.py | LinodeGroup.stackscripts | def stackscripts(self, *filters, **kwargs):
"""
Returns a list of :any:`StackScripts<StackScript>`, both public and
private. You may filter this query to return only
:any:`StackScripts<StackScript>` that match certain criteria. You may
also request only your own private :any:`S... | python | def stackscripts(self, *filters, **kwargs):
"""
Returns a list of :any:`StackScripts<StackScript>`, both public and
private. You may filter this query to return only
:any:`StackScripts<StackScript>` that match certain criteria. You may
also request only your own private :any:`S... | Returns a list of :any:`StackScripts<StackScript>`, both public and
private. You may filter this query to return only
:any:`StackScripts<StackScript>` that match certain criteria. You may
also request only your own private :any:`StackScripts<StackScript>`::
my_stackscripts = client... | https://github.com/linode/linode_api4-python/blob/1dd7318d2aed014c746d48c7957464c57af883ca/linode_api4/linode_client.py#L67-L98 |
linode/linode_api4-python | linode_api4/linode_client.py | LinodeGroup.instance_create | def instance_create(self, ltype, region, image=None,
authorized_keys=None, **kwargs):
"""
Creates a new Linode Instance. This function has several modes of operation:
**Create an Instance from an Image**
To create an Instance from an :any:`Image`, call `instance_create` wit... | python | def instance_create(self, ltype, region, image=None,
authorized_keys=None, **kwargs):
"""
Creates a new Linode Instance. This function has several modes of operation:
**Create an Instance from an Image**
To create an Instance from an :any:`Image`, call `instance_create` wit... | Creates a new Linode Instance. This function has several modes of operation:
**Create an Instance from an Image**
To create an Instance from an :any:`Image`, call `instance_create` with
a :any:`Type`, a :any:`Region`, and an :any:`Image`. All three of
these fields may be provided as e... | https://github.com/linode/linode_api4-python/blob/1dd7318d2aed014c746d48c7957464c57af883ca/linode_api4/linode_client.py#L113-L266 |
linode/linode_api4-python | linode_api4/linode_client.py | LinodeGroup.stackscript_create | def stackscript_create(self, label, script, images, desc=None, public=False, **kwargs):
"""
Creates a new :any:`StackScript` on your account.
:param label: The label for this StackScript.
:type label: str
:param script: The script to run when an :any:`Instance` is deployed with
... | python | def stackscript_create(self, label, script, images, desc=None, public=False, **kwargs):
"""
Creates a new :any:`StackScript` on your account.
:param label: The label for this StackScript.
:type label: str
:param script: The script to run when an :any:`Instance` is deployed with
... | Creates a new :any:`StackScript` on your account.
:param label: The label for this StackScript.
:type label: str
:param script: The script to run when an :any:`Instance` is deployed with
this StackScript. Must begin with a shebang (#!).
:type script: str
... | https://github.com/linode/linode_api4-python/blob/1dd7318d2aed014c746d48c7957464c57af883ca/linode_api4/linode_client.py#L268-L326 |
linode/linode_api4-python | linode_api4/linode_client.py | ProfileGroup.token_create | def token_create(self, label=None, expiry=None, scopes=None, **kwargs):
"""
Creates and returns a new Personal Access Token
"""
if label:
kwargs['label'] = label
if expiry:
if isinstance(expiry, datetime):
expiry = datetime.strftime(expiry,... | python | def token_create(self, label=None, expiry=None, scopes=None, **kwargs):
"""
Creates and returns a new Personal Access Token
"""
if label:
kwargs['label'] = label
if expiry:
if isinstance(expiry, datetime):
expiry = datetime.strftime(expiry,... | Creates and returns a new Personal Access Token | https://github.com/linode/linode_api4-python/blob/1dd7318d2aed014c746d48c7957464c57af883ca/linode_api4/linode_client.py#L358-L378 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.