# Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # """Wrapper and utility functions around sqlite3""" import sqlite3 from typing import List, Optional from memdf import Config, ConfigDescription CONFIG: ConfigDescription = { Config.group_def('database'): { 'title': 'database options', }, 'database.file': { 'help': 'Sqlite3 file', 'metavar': 'FILENAME', 'default': ':memory:', 'argparse': { 'alias': ['--db'], }, }, } class Database: """Wrapper and utility functions around sqlite3"""
from memdf.collector.util import simplify_source PREFIX_CONFIG: ConfigDescription = { 'collect.prefix': { 'help': 'Strip PATH from the beginning of source file names', 'metavar': 'PATH', 'default': [], 'argparse': { 'alias': ['--prefix', '--strip-prefix'], 'action': 'append', } }, } CONFIG: ConfigDescription = { Config.group_def('input'): { 'title': 'input options', }, Config.group_def('tool'): { 'title': 'external tool options', }, Config.group_map('collect'): { 'group': 'input' }, **memdf.collector.bloaty.CONFIG, **memdf.collector.csv.CONFIG, **memdf.collector.elftools.CONFIG, **memdf.collector.readelf.CONFIG, 'collect.method': { 'help': 'Method of input processing', 'metavar': 'METHOD',
'metavar': 'NAME', 'default': [], }, f'{key}.ignore-all': { 'help': f'Ignore all {key}s unless explicitly selected', 'default': False, }, } SECTION_CONFIG = select_and_ignore_config_desc('section') SYMBOL_CONFIG = select_and_ignore_config_desc('symbol') REGION_CONFIG = select_and_ignore_config_desc('region') CONFIG: ConfigDescription = { Config.group_def('select'): { 'title': 'selection options', }, **SECTION_CONFIG, **SYMBOL_CONFIG, **REGION_CONFIG, } COLLECTED_CHOICES = ['symbol', 'section'] SYNTHETIC_CHOICES = ['region'] SELECTION_CHOICES = COLLECTED_CHOICES + SYNTHETIC_CHOICES def is_selected(config: Config, column, name) -> bool: """Test `name` against the configured selection criteria for `column`.""" if config.getl([column, 'select-all']):
persist = new_persist return rows def hierify(df: pd.DataFrame) -> pd.DataFrame: columns = list(df.columns) rows = hierify_rows(df.itertuples(index=False)) r = pd.DataFrame(rows, columns=columns) r.attrs = df.attrs return r # Output OUTPUT_FILE_CONFIG: ConfigDescription = { Config.group_def('output'): { 'title': 'output options', }, 'output.file': { 'help': 'Output file', 'metavar': 'FILENAME', 'default': None, 'argparse': { 'alias': ['--output', '-O'], }, }, } def postprocess_output_metadata(config: Config, key: str, info: Mapping) -> None:
from pathlib import Path from typing import Dict, IO, Iterable, Optional, Union import dateutil # type: ignore import fastcore # type: ignore import ghapi.all # type: ignore import pandas as pd # type: ignore import memdf.report import memdf.util.config import memdf.util.sqlite from memdf import Config, ConfigDescription GITHUB_CONFIG: ConfigDescription = { Config.group_def('github'): { 'title': 'github options', }, 'github.token': { 'help': 'Github API token, or "SKIP" to suppress connecting to github', 'metavar': 'TOKEN', 'default': '', 'argparse': { 'alias': ['--github-api-token', '--token'], }, }, 'github.repository': { 'help': 'Github repostiory', 'metavar': 'OWNER/REPO', 'default': '', 'argparse': {
from typing import Dict import fastcore # type: ignore import pandas as pd # type: ignore import memdf.report import memdf.sizedb import memdf.util.config import memdf.util.markdown import memdf.util.sqlite from memdf.util.github import Gh from memdf import Config, ConfigDescription DB_CONFIG: ConfigDescription = { Config.group_def('database'): { 'title': 'database options', }, 'database.readonly': { 'help': 'Open database read only', 'default': False, 'argparse': { 'alias': ['--db-readonly'], }, }, } GITHUB_CONFIG: ConfigDescription = { Config.group_def('github'): { 'title': 'github options', },