diff --git a/bin/viewtsv.py b/bin/viewtsv.py index 187f022b7..cddf1dd1a 100755 --- a/bin/viewtsv.py +++ b/bin/viewtsv.py @@ -7,7 +7,7 @@ @VisiData.api def open_tsv(vd, p): - return MinimalTsvSheet(p.name, source=p) + return MinimalTsvSheet(p.base_stem, source=p) class MinimalTsvSheet(Sheet): diff --git a/dev/design/path.md b/dev/design/path.md index 38190a7b3..44bdc3f44 100644 --- a/dev/design/path.md +++ b/dev/design/path.md @@ -16,15 +16,13 @@ Additions to pathlib.Path: - adds 'b' to the mode before passing to _open() - vd.Path.__iter__() - incorporates Progress() tracking into file reading +- `.base_stem`: filename *without* any extensions Differences from pathlib.Path: -- `.name`: filename *without* extension - - TODO: change uses of Path.name to Path.stem - visidata.Path.iterdir returns a list and pathlib.Path.iterdir returns a generator - `visidata.Path._open()` - handles uncompressing before passing to pathlib.Path.open() TODO: -- pathlib.Path has a property suffixes which has a list of the path's file extensions - change DirSheet owner/group to Path.owner()/group() - move __iter__ off visidata.Path into global function diff --git a/docs/api/loaders.rst b/docs/api/loaders.rst index 0483097a2..0c7338657 100644 --- a/docs/api/loaders.rst +++ b/docs/api/loaders.rst @@ -25,7 +25,7 @@ Step 1. ``open_`` boilerplate @VisiData.api def open_readme(vd, p): - return ReadmeSheet(p.name, source=p) + return ReadmeSheet(p.base_stem, source=p) This is used for filetype ``readme``, which is used for files with extension ``.readme``, or when specified manually with the ``filetype`` option like ``--filetype=readme`` or ``-f readme`` on the command line. @@ -244,7 +244,7 @@ This is a completely functional loader for the ``sas7bdat`` (SAS dataset file) f @VisiData.api def open_sas7bdat(vd, p): - return SasSheet(p.name, source=p) + return SasSheet(p.base_stem, source=p) class SasSheet(Sheet): def iterload(self): diff --git a/visidata/_open.py b/visidata/_open.py index 58681258b..424640595 100644 --- a/visidata/_open.py +++ b/visidata/_open.py @@ -102,7 +102,7 @@ def openPath(vd, p, filetype=None, create=False): newfunc = getattr(vd, 'new_' + filetype, vd.getGlobals().get('new_' + filetype)) if not newfunc: vd.warning('%s does not exist, creating new sheet' % p) - return vd.newSheet(p.name, 1, source=p) + return vd.newSheet(p.base_stem, 1, source=p) vd.status('creating blank %s' % (p.given)) return newfunc(p) @@ -177,8 +177,8 @@ def open_txt(vd, p): if delimiter and delimiter in next(fp): # peek at the first line return vd.open_tsv(p) # TSV often have .txt extension except StopIteration: - return TableSheet(p.name, columns=[SettableColumn()], source=p) - return TextSheet(p.name, source=p) + return TableSheet(p.base_stem, columns=[SettableColumn()], source=p) + return TextSheet(p.base_stem, source=p) BaseSheet.addCommand('o', 'open-file', 'vd.push(openSource(inputFilename("open: "), create=True))', 'Open file or URL') diff --git a/visidata/apps/vdsql/_ibis.py b/visidata/apps/vdsql/_ibis.py index 545672b6f..eb2b2ab7b 100644 --- a/visidata/apps/vdsql/_ibis.py +++ b/visidata/apps/vdsql/_ibis.py @@ -67,7 +67,7 @@ def open_vdsql(vd, p, filetype=None): if p.ext in ext_aliases: setattr(ibis, p.ext, ext_aliases.get(p.ext)) - return IbisTableIndexSheet(p.name, source=p, filetype=None, database_name=None, + return IbisTableIndexSheet(p.base_stem, source=p, filetype=None, database_name=None, ibis_conpool=IbisConnectionPool(p), sheet_type=IbisTableSheet) vd.open_ibis = vd.open_vdsql diff --git a/visidata/apps/vdsql/bigquery.py b/visidata/apps/vdsql/bigquery.py index 33a19dea0..f60d080b4 100644 --- a/visidata/apps/vdsql/bigquery.py +++ b/visidata/apps/vdsql/bigquery.py @@ -15,7 +15,7 @@ def openurl_bigquery(vd, p, filetype=None): vd.configure_ibis() vd.configure_bigquery() - return BigqueryDatabaseIndexSheet(p.name, source=p, ibis_con=None) + return BigqueryDatabaseIndexSheet(p.base_stem, source=p, ibis_con=None) vd.openurl_bq = vd.openurl_bigquery diff --git a/visidata/apps/vdsql/clickhouse.py b/visidata/apps/vdsql/clickhouse.py index 89c725f32..491849399 100644 --- a/visidata/apps/vdsql/clickhouse.py +++ b/visidata/apps/vdsql/clickhouse.py @@ -8,7 +8,7 @@ @VisiData.api def openurl_clickhouse(vd, p, filetype=None): vd.configure_ibis() - return IbisTableIndexSheet(p.name, source=p, filetype=None, database_name=None, + return IbisTableIndexSheet(p.base_stem, source=p, filetype=None, database_name=None, ibis_conpool=IbisConnectionPool(p), sheet_type=ClickhouseSheet) vd.openurl_clickhouses = vd.openurl_clickhouse diff --git a/visidata/apps/vdsql/snowflake.py b/visidata/apps/vdsql/snowflake.py index 597195474..33ab78309 100644 --- a/visidata/apps/vdsql/snowflake.py +++ b/visidata/apps/vdsql/snowflake.py @@ -7,7 +7,7 @@ @VisiData.api def openurl_snowflake(vd, p, filetype=None): - return IbisTableIndexSheet(p.name, source=p, filetype=None, database_name=None, + return IbisTableIndexSheet(p.base_stem, source=p, filetype=None, database_name=None, ibis_conpool=IbisConnectionPool(p), sheet_type=SnowflakeSheet) diff --git a/visidata/apps/vgit/repos.py b/visidata/apps/vgit/repos.py index faf8e206c..8c156f9b5 100644 --- a/visidata/apps/vgit/repos.py +++ b/visidata/apps/vgit/repos.py @@ -15,7 +15,7 @@ def open_git(vd, p): @VisiData.api def git_repos(vd, p, args): - return GitRepos(p.name, source=p) + return GitRepos(p.base_stem, source=p) class GitLinesColumn(Column): diff --git a/visidata/apps/vgit/status.py b/visidata/apps/vgit/status.py index e709fcb21..c7604b1d2 100644 --- a/visidata/apps/vgit/status.py +++ b/visidata/apps/vgit/status.py @@ -112,7 +112,7 @@ def remotediff(self): return self.gitBranchStatuses.get(self.branch, 'no branch') def iterload(self): - files = [GitFile(p, self.source) for p in self.source.iterdir() if p.name not in ('.git')] # files in working dir + files = [GitFile(p, self.source) for p in self.source.iterdir() if p.base_stem not in ('.git')] # files in working dir filenames = dict((gf.filename, gf) for gf in files) diff --git a/visidata/cmdlog.py b/visidata/cmdlog.py index fe96a86df..d5300045e 100644 --- a/visidata/cmdlog.py +++ b/visidata/cmdlog.py @@ -30,11 +30,11 @@ def queueCommand(vd, longname, input=None, sheet=None, col=None, row=None): @VisiData.api def open_vd(vd, p): - return CommandLog(p.name, source=p, precious=True) + return CommandLog(p.base_stem, source=p, precious=True) @VisiData.api def open_vdj(vd, p): - return CommandLogJsonl(p.name, source=p, precious=True) + return CommandLogJsonl(p.base_stem, source=p, precious=True) VisiData.save_vd = VisiData.save_tsv diff --git a/visidata/deprecated.py b/visidata/deprecated.py index a0076c9da..1585c0a20 100644 --- a/visidata/deprecated.py +++ b/visidata/deprecated.py @@ -73,7 +73,7 @@ def exec_keystrokes(self, keystrokes, vdglobals=None): @VisiData.api def filetype(vd, ext, constructor): 'Add constructor to handle the given file type/extension.' - globals().setdefault('open_'+ext, lambda p,ext=ext: constructor(p.name, source=p, filetype=ext)) + globals().setdefault('open_'+ext, lambda p,ext=ext: constructor(p.base_stem, source=p, filetype=ext)) @deprecated('2.0', 'Sheet(namepart1, namepart2, ...)') @VisiData.global_api diff --git a/visidata/experimental/gdrive.py b/visidata/experimental/gdrive.py index 02596dafb..ca4165c11 100644 --- a/visidata/experimental/gdrive.py +++ b/visidata/experimental/gdrive.py @@ -5,7 +5,7 @@ @VisiData.api def open_gdrive(vd, p): - return GDriveSheet(p.name) + return GDriveSheet(p.base_stem) FILES_FIELDS_VISIBLE='''name size modifiedTime mimeType description'''.split() diff --git a/visidata/experimental/gsheets.py b/visidata/experimental/gsheets.py index bd9919bda..35bb22036 100644 --- a/visidata/experimental/gsheets.py +++ b/visidata/experimental/gsheets.py @@ -8,7 +8,7 @@ def open_gsheets(vd, p): m = re.search(r'([A-z0-9_]{44})', p.given) if m: - return GSheetsIndex(p.name, source=m.groups()[0]) + return GSheetsIndex(p.base_stem, source=m.groups()[0]) vd.open_g = vd.open_gsheets @@ -57,7 +57,7 @@ def iterload(self): @VisiData.api def save_gsheets(vd, p, *sheets): gsheet = vd._gsheets_rw.create(body={ - 'properties': { 'title': p.name }, + 'properties': { 'title': p.base_stem }, 'sheets': list({'properties': { 'title': vs.name }} for vs in sheets), }, fields='spreadsheetId').execute() diff --git a/visidata/form.py b/visidata/form.py index a1cea1337..1c459c7c0 100644 --- a/visidata/form.py +++ b/visidata/form.py @@ -4,7 +4,7 @@ @VisiData.api def open_mnu(vd, p): - return FormSheet(p.name, source=p) + return FormSheet(p.base_stem, source=p) vd.save_mnu=vd.save_tsv diff --git a/visidata/loaders/_pandas.py b/visidata/loaders/_pandas.py index 3b92c916f..fe35bcfde 100644 --- a/visidata/loaders/_pandas.py +++ b/visidata/loaders/_pandas.py @@ -4,18 +4,18 @@ @VisiData.api def open_pandas(vd, p): - return PandasSheet(p.name, source=p) + return PandasSheet(p.base_stem, source=p) @VisiData.api def open_dta(vd, p): - return PandasSheet(p.name, source=p, filetype='stata') + return PandasSheet(p.base_stem, source=p, filetype='stata') VisiData.open_stata = VisiData.open_pandas for ft in 'feather gbq orc pickle sas stata'.split(): funcname ='open_'+ft if not getattr(VisiData, funcname, None): - setattr(VisiData, funcname, lambda vd,p,ft=ft: PandasSheet(p.name, source=p, filetype=ft)) + setattr(VisiData, funcname, lambda vd,p,ft=ft: PandasSheet(p.base_stem, source=p, filetype=ft)) @VisiData.api @asyncthread diff --git a/visidata/loaders/api_bitio.py b/visidata/loaders/api_bitio.py index c1a367a58..c933ec0e1 100644 --- a/visidata/loaders/api_bitio.py +++ b/visidata/loaders/api_bitio.py @@ -7,7 +7,7 @@ def new_bitio(vd, p): vd.importExternal('bitdotio') vd.requireOptions('bitio_api_key', help='https://docs.bit.io/docs/connecting-via-the-api') - return BitioReposSheet(p.name, source=p) + return BitioReposSheet(p.base_stem, source=p) vd.openhttp_bitio = vd.new_bitio diff --git a/visidata/loaders/api_matrix.py b/visidata/loaders/api_matrix.py index ae9422aa7..4f8bb679a 100644 --- a/visidata/loaders/api_matrix.py +++ b/visidata/loaders/api_matrix.py @@ -32,7 +32,7 @@ def openhttp_matrix(vd, p): vd.setPersistentOptions(matrix_user_id=username, matrix_token=matrix_token) vd.timeouts_before_idle = -1 - return MatrixSheet(p.name, source=p) + return MatrixSheet(p.base_stem, source=p) vd.open_matrix = vd.openhttp_matrix diff --git a/visidata/loaders/api_reddit.py b/visidata/loaders/api_reddit.py index 5b2fb9251..3a5df2bb7 100644 --- a/visidata/loaders/api_reddit.py +++ b/visidata/loaders/api_reddit.py @@ -27,12 +27,12 @@ def open_reddit(vd, p): return RedditGuide('reddit_guide') if p.given.startswith('r/') or p.given.startswith('/r/'): - return SubredditSheet(p.name, source=p.name.split('+'), search=(p.given[0]=='/')) + return SubredditSheet(p.base_stem, source=p.base_stem.split('+'), search=(p.given[0]=='/')) if p.given.startswith('u/') or p.given.startswith('/u/'): - return RedditorsSheet(p.name, source=p.name.split('+'), search=(p.given[0]=='/')) + return RedditorsSheet(p.base_stem, source=p.base_stem.split('+'), search=(p.given[0]=='/')) - return SubredditSheet(p.name, source=p) + return SubredditSheet(p.base_stem, source=p) vd.new_reddit = vd.open_reddit diff --git a/visidata/loaders/archive.py b/visidata/loaders/archive.py index 6fc8ee69b..6af048b89 100644 --- a/visidata/loaders/archive.py +++ b/visidata/loaders/archive.py @@ -20,11 +20,11 @@ def guess_tar(vd, p): @VisiData.api def open_zip(vd, p): - return vd.ZipSheet(p.name, source=p) + return vd.ZipSheet(p.base_stem, source=p) @VisiData.api def open_tar(vd, p): - return TarSheet(p.name, source=p) + return TarSheet(p.base_stem, source=p) VisiData.open_tgz = VisiData.open_tar VisiData.open_txz = VisiData.open_tar diff --git a/visidata/loaders/arrow.py b/visidata/loaders/arrow.py index f58a507c6..18ca049d3 100644 --- a/visidata/loaders/arrow.py +++ b/visidata/loaders/arrow.py @@ -7,13 +7,13 @@ @VisiData.api def open_arrow(vd, p): 'Apache Arrow IPC file format' - return ArrowSheet(p.name, source=p) + return ArrowSheet(p.base_stem, source=p) @VisiData.api def open_arrows(vd, p): 'Apache Arrow IPC streaming format' - return ArrowSheet(p.name, source=p) + return ArrowSheet(p.base_stem, source=p) def arrow_to_vdtype(t): diff --git a/visidata/loaders/conll.py b/visidata/loaders/conll.py index 3ad86dde8..f4d094858 100644 --- a/visidata/loaders/conll.py +++ b/visidata/loaders/conll.py @@ -4,12 +4,12 @@ @VisiData.api def open_conll(vd, p): - return ConllSheet(p.name, source=p) + return ConllSheet(p.base_stem, source=p) @VisiData.api def open_conllu(vd, p): - return ConllSheet(p.name, source=p) + return ConllSheet(p.base_stem, source=p) class ConllSheet(TableSheet): diff --git a/visidata/loaders/csv.py b/visidata/loaders/csv.py index 21e0143b5..a926a6076 100644 --- a/visidata/loaders/csv.py +++ b/visidata/loaders/csv.py @@ -27,7 +27,7 @@ def guess_csv(vd, p): @VisiData.api def open_csv(vd, p): - return CsvSheet(p.name, source=p) + return CsvSheet(p.base_stem, source=p) def removeNulls(fp): for line in fp: diff --git a/visidata/loaders/eml.py b/visidata/loaders/eml.py index 722739b49..a3ac067ab 100644 --- a/visidata/loaders/eml.py +++ b/visidata/loaders/eml.py @@ -4,7 +4,7 @@ @VisiData.api def open_eml(vd, p): - return EmailSheet(p.name, source=p) + return EmailSheet(p.base_stem, source=p) class EmailSheet(TableSheet): rowtype = 'parts' # rowdef: sub-Messages diff --git a/visidata/loaders/f5log.py b/visidata/loaders/f5log.py index c15bcd29f..0b97d331f 100644 --- a/visidata/loaders/f5log.py +++ b/visidata/loaders/f5log.py @@ -1175,6 +1175,6 @@ def iterload(self): @VisiData.api def open_f5log(vd: VisiData, p: Path) -> Sheet: - sheet = F5LogSheet(p.name, source=p) + sheet = F5LogSheet(p.base_stem, source=p) sheet.options["disp_date_fmt"] = "%Y-%m-%d %H:%M:%S" return sheet diff --git a/visidata/loaders/fec.py b/visidata/loaders/fec.py index e95f4c5c4..0e5168e14 100644 --- a/visidata/loaders/fec.py +++ b/visidata/loaders/fec.py @@ -317,7 +317,7 @@ def addSheetRow(component_name): ) def open_fec(p): - return FECFiling(p.name, source=p) + return FECFiling(p.base_stem, source=p) addGlobals({ "open_fec": open_fec, diff --git a/visidata/loaders/fixed_width.py b/visidata/loaders/fixed_width.py index 0425c0d91..9a215ba1c 100644 --- a/visidata/loaders/fixed_width.py +++ b/visidata/loaders/fixed_width.py @@ -7,7 +7,7 @@ @VisiData.api def open_fixed(vd, p): - return FixedWidthColumnsSheet(p.name, source=p, headerlines=[]) + return FixedWidthColumnsSheet(p.base_stem, source=p, headerlines=[]) class FixedWidthColumn(Column): def __init__(self, name, i, j, **kwargs): diff --git a/visidata/loaders/frictionless.py b/visidata/loaders/frictionless.py index 1940c65b7..67955277e 100644 --- a/visidata/loaders/frictionless.py +++ b/visidata/loaders/frictionless.py @@ -2,7 +2,7 @@ @VisiData.api def open_frictionless(vd, p): - return FrictionlessIndexSheet(p.name, source=p) + return FrictionlessIndexSheet(p.base_stem, source=p) class FrictionlessIndexSheet(IndexSheet): def iterload(self): diff --git a/visidata/loaders/geojson.py b/visidata/loaders/geojson.py index f7805d791..4e676cec8 100644 --- a/visidata/loaders/geojson.py +++ b/visidata/loaders/geojson.py @@ -9,7 +9,7 @@ @VisiData.api def open_geojson(vd, p): - return GeoJSONSheet(p.name, source=p) + return GeoJSONSheet(p.base_stem, source=p) class GeoJSONColumn(Column): def calcValue(self, row): diff --git a/visidata/loaders/hdf5.py b/visidata/loaders/hdf5.py index 55d6205d6..2dd624c1f 100644 --- a/visidata/loaders/hdf5.py +++ b/visidata/loaders/hdf5.py @@ -2,7 +2,7 @@ @VisiData.api def open_h5(vd, p): - return Hdf5ObjSheet(p.name, source=p) + return Hdf5ObjSheet(p.base_stem, source=p) VisiData.open_hdf5 = VisiData.open_h5 diff --git a/visidata/loaders/html.py b/visidata/loaders/html.py index 6c15e5d30..cf3672de0 100644 --- a/visidata/loaders/html.py +++ b/visidata/loaders/html.py @@ -22,7 +22,7 @@ def guess_html(vd, p): @VisiData.api def open_html(vd, p): - return HtmlTablesSheet(p.name, source=p) + return HtmlTablesSheet(p.base_stem, source=p) VisiData.open_htm = VisiData.open_html diff --git a/visidata/loaders/jrnl.py b/visidata/loaders/jrnl.py index ca4b61a35..b7074782f 100644 --- a/visidata/loaders/jrnl.py +++ b/visidata/loaders/jrnl.py @@ -8,7 +8,7 @@ @VisiData.api def open_jrnl(vd, p): - return JrnlSheet(p.name, source=p) + return JrnlSheet(p.base_stem, source=p) class JrnlSheet(TableSheet): diff --git a/visidata/loaders/json.py b/visidata/loaders/json.py index 24fe5dd6b..f02de47a8 100644 --- a/visidata/loaders/json.py +++ b/visidata/loaders/json.py @@ -23,11 +23,11 @@ def guess_json(vd, p): @VisiData.api def open_jsonobj(vd, p): - return JsonSheet(p.name, source=p) + return JsonSheet(p.base_stem, source=p) @VisiData.api def open_jsonl(vd, p): - return JsonSheet(p.name, source=p) + return JsonSheet(p.base_stem, source=p) VisiData.open_ndjson = VisiData.open_ldjson = VisiData.open_json = VisiData.open_jsonl diff --git a/visidata/loaders/jsonla.py b/visidata/loaders/jsonla.py index aac329342..d1b67c0de 100644 --- a/visidata/loaders/jsonla.py +++ b/visidata/loaders/jsonla.py @@ -28,7 +28,7 @@ def guess_jsonla(vd, p): @VisiData.api def open_jsonla(vd, p): - return JsonlArraySheet(p.name, source=p) + return JsonlArraySheet(p.base_stem, source=p) class JsonlArraySheet(SequenceSheet): diff --git a/visidata/loaders/lsv.py b/visidata/loaders/lsv.py index cd0144b51..61a1a96ac 100644 --- a/visidata/loaders/lsv.py +++ b/visidata/loaders/lsv.py @@ -7,7 +7,7 @@ @VisiData.api def open_lsv(vd, p): - return LsvSheet(p.name, source=p) + return LsvSheet(p.base_stem, source=p) @VisiData.api diff --git a/visidata/loaders/mailbox.py b/visidata/loaders/mailbox.py index 1a9827d91..fb527218c 100644 --- a/visidata/loaders/mailbox.py +++ b/visidata/loaders/mailbox.py @@ -3,23 +3,23 @@ @VisiData.api def open_mbox(vd, p): - return MboxSheet(p.name, source=p, format='mbox') + return MboxSheet(p.base_stem, source=p, format='mbox') @VisiData.api def open_maildir(vd, p): - return MboxSheet(p.name, source=p, format='Maildir') + return MboxSheet(p.base_stem, source=p, format='Maildir') @VisiData.api def open_mmdf(vd, p): - return MboxSheet(p.name, source=p, format='MMDF') + return MboxSheet(p.base_stem, source=p, format='MMDF') @VisiData.api def open_babyl(vd, p): - return MboxSheet(p.name, source=p, format='Babyl') + return MboxSheet(p.base_stem, source=p, format='Babyl') @VisiData.api def open_mh(vd, p): - return MboxSheet(p.name, source=p, format='MH') + return MboxSheet(p.base_stem, source=p, format='MH') class MboxSheet(Sheet): diff --git a/visidata/loaders/mbtiles.py b/visidata/loaders/mbtiles.py index 1e60599e9..73f6872aa 100644 --- a/visidata/loaders/mbtiles.py +++ b/visidata/loaders/mbtiles.py @@ -5,11 +5,11 @@ @VisiData.api def open_pbf(vd, p): - return PbfSheet(p.name, source=p) + return PbfSheet(p.base_stem, source=p) @VisiData.api def open_mbtiles(vd, p): - return MbtilesSheet(p.name, source=p) + return MbtilesSheet(p.base_stem, source=p) def getListDepth(L): if not isinstance(L, list): diff --git a/visidata/loaders/npy.py b/visidata/loaders/npy.py index 3fd70a0b9..3f86bb1c5 100644 --- a/visidata/loaders/npy.py +++ b/visidata/loaders/npy.py @@ -4,11 +4,11 @@ @VisiData.api def open_npy(vd, p): - return NpySheet(p.name, source=p) + return NpySheet(p.base_stem, source=p) @VisiData.api def open_npz(vd, p): - return NpzSheet(p.name, source=p) + return NpzSheet(p.base_stem, source=p) vd.option('npy_allow_pickle', False, 'numpy allow unpickling objects (unsafe)') diff --git a/visidata/loaders/odf.py b/visidata/loaders/odf.py index 929ef4fd1..8a0b3f8da 100644 --- a/visidata/loaders/odf.py +++ b/visidata/loaders/odf.py @@ -3,7 +3,7 @@ @VisiData.api def open_ods(vd, p): - return OdsIndexSheet(p.name, source=p) + return OdsIndexSheet(p.base_stem, source=p) class OdsIndexSheet(IndexSheet): diff --git a/visidata/loaders/orgmode.py b/visidata/loaders/orgmode.py index 662519769..7afaef76f 100644 --- a/visidata/loaders/orgmode.py +++ b/visidata/loaders/orgmode.py @@ -31,17 +31,17 @@ @VisiData.api def open_org(vd, p): - return OrgSheet(p.name, source=p, filetype='org') + return OrgSheet(p.base_stem, source=p, filetype='org') @VisiData.api def open_forg(vd, p): - return OrgSheet(p.name, source=p, filetype='forg') + return OrgSheet(p.base_stem, source=p, filetype='forg') @VisiData.api def open_orgdir(vd, p): - return OrgSheet(p.name, source=p, filetype='orgdir') + return OrgSheet(p.base_stem, source=p, filetype='orgdir') def encode_date(dt=None): @@ -246,7 +246,7 @@ def _walkfiles(p): if self.filetype == 'orgdir': basepath = str(self.source) for p in _walkfiles(self.source): - if p.name.startswith('.'): continue + if p.base_stem.startswith('.'): continue if p.ext in ['org', 'md']: yield self.parse_orgmd(p) elif self.filetype == 'forg': diff --git a/visidata/loaders/parquet.py b/visidata/loaders/parquet.py index 50ca020ed..d822cae3f 100644 --- a/visidata/loaders/parquet.py +++ b/visidata/loaders/parquet.py @@ -4,7 +4,7 @@ @VisiData.api def open_parquet(vd, p): - return ParquetSheet(p.name, source=p) + return ParquetSheet(p.base_stem, source=p) class ParquetColumn(Column): diff --git a/visidata/loaders/pcap.py b/visidata/loaders/pcap.py index 1bd294f01..190c03869 100644 --- a/visidata/loaders/pcap.py +++ b/visidata/loaders/pcap.py @@ -17,7 +17,7 @@ @VisiData.api def open_pcap(vd, p): - return PcapSheet(p.name, source=p) + return PcapSheet(p.base_stem, source=p) open_cap = open_pcap open_pcapng = open_pcap diff --git a/visidata/loaders/pdf.py b/visidata/loaders/pdf.py index 4a6a044b0..ce8659eab 100644 --- a/visidata/loaders/pdf.py +++ b/visidata/loaders/pdf.py @@ -8,8 +8,8 @@ @VisiData.api def open_pdf(vd, p): if vd.options.pdf_tables: - return TabulaSheet(p.name, source=p) - return PdfMinerSheet(p.name, source=p) + return TabulaSheet(p.base_stem, source=p) + return PdfMinerSheet(p.base_stem, source=p) class PdfMinerSheet(TableSheet): diff --git a/visidata/loaders/png.py b/visidata/loaders/png.py index 44f429343..ec13c69e9 100644 --- a/visidata/loaders/png.py +++ b/visidata/loaders/png.py @@ -5,7 +5,7 @@ @VisiData.api def open_png(vd, p): - return PNGSheet(p.name, source=p) + return PNGSheet(p.base_stem, source=p) class PNGSheet(Sheet): diff --git a/visidata/loaders/rec.py b/visidata/loaders/rec.py index 1b9a7fd72..6c70a0b0f 100644 --- a/visidata/loaders/rec.py +++ b/visidata/loaders/rec.py @@ -5,7 +5,7 @@ @VisiData.api def open_rec(vd, p): - return RecIndexSheet(p.name, source=p) + return RecIndexSheet(p.base_stem, source=p) def decode_multiline(line, fp): 'Parse *line* and lookahead into *fp* as iterator for continuing lines. Return (multiline, next_line) where *multiline* can contain newlines and *next_line is the line after the combined *multiline*. Handle "\\" at end and "+" at beginning of lines. *next_line* will be None iff iterator is exhausted.' diff --git a/visidata/loaders/s3.py b/visidata/loaders/s3.py index 3507e6ec0..627e6abd3 100644 --- a/visidata/loaders/s3.py +++ b/visidata/loaders/s3.py @@ -239,7 +239,7 @@ def openurl_s3(vd, p, filetype): p.fs.connect() if not p.fs.isfile(str(p.given)): - return S3DirSheet(p.name, source=p, version_aware=p.version_aware) + return S3DirSheet(p.base_stem, source=p, version_aware=p.version_aware) if not filetype: filetype = p.ext or "txt" diff --git a/visidata/loaders/sas.py b/visidata/loaders/sas.py index d92ed2db5..a5b7cb249 100644 --- a/visidata/loaders/sas.py +++ b/visidata/loaders/sas.py @@ -9,11 +9,11 @@ @VisiData.api def open_xpt(vd, p): - return XptSheet(p.name, source=p) + return XptSheet(p.base_stem, source=p) @VisiData.api def open_sas7bdat(vd, p): - return SasSheet(p.name, source=p) + return SasSheet(p.base_stem, source=p) class XptSheet(Sheet): def iterload(self): diff --git a/visidata/loaders/scrape.py b/visidata/loaders/scrape.py index e11c7f146..846e7c60f 100755 --- a/visidata/loaders/scrape.py +++ b/visidata/loaders/scrape.py @@ -24,9 +24,9 @@ def open_scrape(vd, p): vd.enable_requests_cache() if p.is_url(): - return HtmlDocsSheet(p.name, source=p, urls=[p.given]) + return HtmlDocsSheet(p.base_stem, source=p, urls=[p.given]) else: - return HtmlElementsSheet(p.name, source=p, elements=None) + return HtmlElementsSheet(p.base_stem, source=p, elements=None) VisiData.openhttp_scrape = VisiData.open_scrape diff --git a/visidata/loaders/shp.py b/visidata/loaders/shp.py index 8c3c8a130..d598900e0 100644 --- a/visidata/loaders/shp.py +++ b/visidata/loaders/shp.py @@ -8,7 +8,7 @@ @VisiData.api def open_shp(vd, p): - return ShapeSheet(p.name, source=p) + return ShapeSheet(p.base_stem, source=p) VisiData.open_dbf = VisiData.open_shp diff --git a/visidata/loaders/spss.py b/visidata/loaders/spss.py index 56a849735..0b374d917 100644 --- a/visidata/loaders/spss.py +++ b/visidata/loaders/spss.py @@ -3,7 +3,7 @@ @VisiData.api def open_spss(vd, p): - return SpssSheet(p.name, source=p) + return SpssSheet(p.base_stem, source=p) VisiData.open_sav = VisiData.open_spss diff --git a/visidata/loaders/sqlite.py b/visidata/loaders/sqlite.py index 389470588..f8a9ecd49 100644 --- a/visidata/loaders/sqlite.py +++ b/visidata/loaders/sqlite.py @@ -27,11 +27,11 @@ def guess_sqlite(vd, p): def open_sqlite(vd, p): if not p.is_local(): vd.fail('sqlite requires an uncompressed, local file') - return SqliteIndexSheet(p.name, source=p) + return SqliteIndexSheet(p.base_stem, source=p) @VisiData.api def openurl_sqlite(vd, p, filetype=None): - return SqliteIndexSheet(p.name, source=p) + return SqliteIndexSheet(p.base_stem, source=p) VisiData.open_sqlite3 = VisiData.open_sqlite VisiData.open_db = VisiData.open_sqlite diff --git a/visidata/loaders/toml.py b/visidata/loaders/toml.py index 9cb98c6aa..7ec99c7da 100644 --- a/visidata/loaders/toml.py +++ b/visidata/loaders/toml.py @@ -10,7 +10,7 @@ @VisiData.api def open_toml(vd, p): - return TomlSheet(p.name, source=p) + return TomlSheet(p.base_stem, source=p) class TomlSheet(PythonSheet): diff --git a/visidata/loaders/tsv.py b/visidata/loaders/tsv.py index be7b20e22..4f66b2122 100644 --- a/visidata/loaders/tsv.py +++ b/visidata/loaders/tsv.py @@ -16,7 +16,7 @@ @VisiData.api def open_tsv(vd, p): - return TsvSheet(p.name, source=p) + return TsvSheet(p.base_stem, source=p) def adaptive_bufferer(fp, max_buffer_size=65536): diff --git a/visidata/loaders/ttf.py b/visidata/loaders/ttf.py index ddc014739..1206e477c 100644 --- a/visidata/loaders/ttf.py +++ b/visidata/loaders/ttf.py @@ -3,7 +3,7 @@ @VisiData.api def open_ttf(vd, p): - return TTFTablesSheet(p.name, source=p) + return TTFTablesSheet(p.base_stem, source=p) vd.open_otf = vd.open_ttf diff --git a/visidata/loaders/usv.py b/visidata/loaders/usv.py index a751ffd2f..b2658b424 100644 --- a/visidata/loaders/usv.py +++ b/visidata/loaders/usv.py @@ -4,7 +4,7 @@ @VisiData.api def open_usv(vd, p): - return TsvSheet(p.name, source=p, delimiter='\u241f', row_delimiter='\u241e') + return TsvSheet(p.base_stem, source=p, delimiter='\u241f', row_delimiter='\u241e') @VisiData.api def save_usv(vd, p, vs): diff --git a/visidata/loaders/vcf.py b/visidata/loaders/vcf.py index 1d2ca5bf8..08d1d8ace 100644 --- a/visidata/loaders/vcf.py +++ b/visidata/loaders/vcf.py @@ -5,7 +5,7 @@ @VisiData.api def open_vcf(vd, p): - return VcfSheet(p.name, source=p) + return VcfSheet(p.base_stem, source=p) def unbox(col, row): v = getitemdef(row, col.expr) diff --git a/visidata/loaders/vds.py b/visidata/loaders/vds.py index aba2286c4..a40c21f01 100644 --- a/visidata/loaders/vds.py +++ b/visidata/loaders/vds.py @@ -9,7 +9,7 @@ @VisiData.api def open_vds(vd, p): - return VdsIndexSheet(p.name, source=p) + return VdsIndexSheet(p.base_stem, source=p) @VisiData.api diff --git a/visidata/loaders/vdx.py b/visidata/loaders/vdx.py index 22afdf244..d5d9ec3e6 100644 --- a/visidata/loaders/vdx.py +++ b/visidata/loaders/vdx.py @@ -6,7 +6,7 @@ @VisiData.api def open_vdx(vd, p): - return CommandLogSimple(p.name, source=p, precious=True) + return CommandLogSimple(p.base_stem, source=p, precious=True) class CommandLogSimple(CommandLogBase, Sheet): diff --git a/visidata/loaders/xlsb.py b/visidata/loaders/xlsb.py index 2cc239e99..c1f8ceb78 100644 --- a/visidata/loaders/xlsb.py +++ b/visidata/loaders/xlsb.py @@ -10,7 +10,7 @@ def guess_xls(vd, p): @VisiData.api def open_xlsb(vd, p): - return XlsbIndex(p.name, source=p) + return XlsbIndex(p.base_stem, source=p) class XlsbIndex(IndexSheet): diff --git a/visidata/loaders/xlsx.py b/visidata/loaders/xlsx.py index 72a01bcae..4cba337e7 100644 --- a/visidata/loaders/xlsx.py +++ b/visidata/loaders/xlsx.py @@ -13,11 +13,11 @@ @VisiData.api def open_xls(vd, p): - return XlsIndexSheet(p.name, source=p) + return XlsIndexSheet(p.base_stem, source=p) @VisiData.api def open_xlsx(vd, p): - return XlsxIndexSheet(p.name, source=p) + return XlsxIndexSheet(p.base_stem, source=p) class XlsxIndexSheet(IndexSheet): 'Load XLSX file (in Excel Open XML format).' diff --git a/visidata/loaders/xml.py b/visidata/loaders/xml.py index d49624eb8..0b70a9e83 100644 --- a/visidata/loaders/xml.py +++ b/visidata/loaders/xml.py @@ -6,7 +6,7 @@ @VisiData.api def open_xml(vd, p): - return XmlSheet(p.name, source=p) + return XmlSheet(p.base_stem, source=p) VisiData.open_svg = VisiData.open_xml diff --git a/visidata/loaders/xword.py b/visidata/loaders/xword.py index b5acad39d..5369e814f 100755 --- a/visidata/loaders/xword.py +++ b/visidata/loaders/xword.py @@ -8,13 +8,13 @@ @VisiData.api def open_puz(vd, p): - return PuzSheet(p.name, source=p) + return PuzSheet(p.base_stem, source=p) @VisiData.api def open_xd(vd, p): if p.is_dir(): - return CrosswordsSheet(p.name, source=p) - return CrosswordSheet(p.name, source=p) + return CrosswordsSheet(p.base_stem, source=p) + return CrosswordSheet(p.base_stem, source=p) @VisiData.api diff --git a/visidata/loaders/yaml.py b/visidata/loaders/yaml.py index 766255e14..597beb099 100644 --- a/visidata/loaders/yaml.py +++ b/visidata/loaders/yaml.py @@ -5,7 +5,7 @@ @VisiData.api def open_yml(vd, p): - return YamlSheet(p.name, source=p) + return YamlSheet(p.base_stem, source=p) VisiData.open_yaml = VisiData.open_yml diff --git a/visidata/macros.py b/visidata/macros.py index 4b253027a..d62ad4fdf 100644 --- a/visidata/macros.py +++ b/visidata/macros.py @@ -57,11 +57,11 @@ def macrosheet(vd): def loadMacro(vd, p:Path): if p.exists(): if p.ext == 'vd': - vs = CommandLog(p.name, source=p) + vs = CommandLog(p.base_stem, source=p) vs.ensureLoaded() return vs elif p.ext == 'vdj': - vs = CommandLogJsonl(p.name, source=p) + vs = CommandLogJsonl(p.base_stem, source=p) vs.ensureLoaded() return vs diff --git a/visidata/path.py b/visidata/path.py index 6652a61b6..66bdc135a 100644 --- a/visidata/path.py +++ b/visidata/path.py @@ -186,17 +186,17 @@ def given(self, given): self.ext = self.suffix[1:] if self.suffix: #1450 don't make this a oneliner; [:-0] doesn't work - self.name = self._path.name[:-len(self.suffix)] + self.base_stem = self._path.name[:-len(self.suffix)] elif self._given == '.': #1768 - self.name = self._path.absolute().name + self.base_stem = self._path.absolute().name else: - self.name = self._path.name + self.base_stem = self._path.name # check if file is compressed if self.suffix in ['.gz', '.bz2', '.xz', '.lzma', '.zst']: self.compression = self.ext uncompressedpath = Path(self.given[:-len(self.suffix)]) # strip suffix - self.name = uncompressedpath.name + self.base_stem = uncompressedpath.base_stem self.ext = uncompressedpath.ext else: self.compression = None diff --git a/visidata/shell.py b/visidata/shell.py index 856cf27fa..8622d6ded 100644 --- a/visidata/shell.py +++ b/visidata/shell.py @@ -41,11 +41,11 @@ def exec_shell(*args): @VisiData.api def open_dir(vd, p): - return DirSheet(p.name, source=p) + return DirSheet(p.base_stem, source=p) @VisiData.api def open_fdir(vd, p): - return FileListSheet(p.name, source=p) + return FileListSheet(p.base_stem, source=p) @VisiData.api def addShellColumns(vd, cmd, sheet): diff --git a/visidata/threads.py b/visidata/threads.py index 5fa989824..096f79336 100644 --- a/visidata/threads.py +++ b/visidata/threads.py @@ -305,7 +305,7 @@ def sync(self, *joiningThreads): @VisiData.api def open_pyprof(vd, p): import pstats - return ProfileStatsSheet(p.name, source=pstats.Stats(p.given).stats) + return ProfileStatsSheet(p.base_stem, source=pstats.Stats(p.given).stats) @VisiData.api