FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
vdplugins/vdgs.py at main · seeni-dev/vdplugins · GitHub
seeni-dev
vdplugins
Repository navigation
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
vdplugins
/
vdgs.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
79 lines (61 loc) · 2.16 KB
Breadcrumbs
vdplugins
/
vdgs.py
Copy path
File metadata and controls
79 lines (61 loc) · 2.16 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
from
visidata
import
ENTER
,
Column
,
Path
,
Sheet
,
asyncthread
,
vd
__version__
=
"0.1"
class
GSPath
(
Path
):
blob
=
None
storage_client
=
None
bucket_name
=
None
bucket
=
None
path
=
None
def
__init__
(
self
,
uri
):
super
().
__init__
(
uri
)
path_without_scheme
=
uri
.
split
(
"://"
,
1
)[
1
]
splits
=
path_without_scheme
.
split
(
"/"
,
1
)
self
.
bucket_name
=
splits
[
0
]
self
.
path
=
splits
[
1
]
from
google
.
cloud
import
storage
self
.
storage_client
=
storage
.
Client
()
self
.
bucket
=
self
.
storage_client
.
bucket
(
self
.
bucket_name
)
self
.
blob
=
self
.
bucket
.
blob
(
self
.
path
)
def
open
(
self
,
*
args
,
**
kwargs
):
print
(
args
)
print
(
kwargs
)
return
self
.
blob
.
open
(
*
args
,
**
kwargs
)
def
openurl_gs
(
p
:
Path
,
filetype
):
"""Open a sheet for an GS path.
GS directories (prefixes) require special handling, but files (objects)
can use standard VisiData "open" functions.
"""
# For now, it supports only file.
# TODO support directory browsing
if
not
filetype
:
filetype
=
p
.
ext
or
"txt"
p
=
GSPath
(
p
.
given
)
openfunc
=
getattr
(
vd
,
f"open_
{
filetype
.
lower
()
}
"
)
if
not
openfunc
:
vd
.
warning
(
f"no loader found for
{
filetype
}
files, falling back to txt"
)
filetype
=
"txt"
openfunc
=
vd
.
open_txt
assert
callable
(
openfunc
),
f"no function/method available to open
{
p
.
given
}
"
vs
=
openfunc
(
p
)
vd
.
status
(
f'opening
{
p
.
given
}
as
{
filetype
}
'
)
return
vs
def
vd_getattr
(
self
,
attr
):
"""Fall back to global lookups for missing VisiData attributes.
VisiData is gradually replacing global functions with methods on
the VisiData (vd) object.
Let's try to use vd methods everywhere, but fall back to global
lookups. This could/should let us use current patterns
but also "just work" on older versions.
Note: Avoiding "private" attributes (starting with _) keeps us
from breaking lazy properties.
"""
if
not
attr
.
startswith
(
"_"
):
return
self
.
getGlobals
().
get
(
attr
)
raise
AttributeError
(
attr
)
vd
.
__class__
.
__getattr__
=
vd_getattr
vd
.
addGlobals
(
globals
())
Back
|
FazBrowse Home
|
New Git URL