FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
sourcegraph/internal/repos/python_packages.go at main · NanthR/sourcegraph · GitHub
NanthR
/
sourcegraph
Public
forked from
sourcegraph/sourcegraph-public-snapshot
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
sourcegraph
/
internal
/
repos
/
python_packages.go
Copy path
More file actions
More file actions
Latest commit
History
History
History
65 lines (54 loc) · 2.21 KB
Breadcrumbs
sourcegraph
/
internal
/
repos
/
python_packages.go
Copy path
File metadata and controls
65 lines (54 loc) · 2.21 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
package
repos
import
(
"context"
"github.com/sourcegraph/sourcegraph/internal/api"
"github.com/sourcegraph/sourcegraph/internal/codeintel/dependencies"
"github.com/sourcegraph/sourcegraph/internal/conf/reposource"
"github.com/sourcegraph/sourcegraph/internal/extsvc/pypi"
"github.com/sourcegraph/sourcegraph/internal/httpcli"
"github.com/sourcegraph/sourcegraph/internal/jsonc"
"github.com/sourcegraph/sourcegraph/internal/types"
"github.com/sourcegraph/sourcegraph/lib/errors"
"github.com/sourcegraph/sourcegraph/schema"
)
// NewPythonPackagesSource returns a new PythonPackagesSource from the given external service.
func
NewPythonPackagesSource
(
ctx
context.
Context
,
svc
*
types.
ExternalService
,
cf
*
httpcli.
Factory
) (
*
PackagesSource
,
error
) {
rawConfig
,
err
:=
svc
.
Config
.
Decrypt
(
ctx
)
if
err
!=
nil
{
return
nil
,
errors
.
Errorf
(
"external service id=%d config error: %s"
,
svc
.
ID
,
err
)
}
var
c
schema.
PythonPackagesConnection
if
err
:=
jsonc
.
Unmarshal
(
rawConfig
,
&
c
);
err
!=
nil
{
return
nil
,
errors
.
Errorf
(
"external service id=%d config error: %s"
,
svc
.
ID
,
err
)
}
cli
,
err
:=
cf
.
Doer
()
if
err
!=
nil
{
return
nil
,
err
}
return
&
PackagesSource
{
svc
:
svc
,
configDeps
:
c
.
Dependencies
,
scheme
:
dependencies
.
PythonPackagesScheme
,
src
:
&
pythonPackagesSource
{
client
:
pypi
.
NewClient
(
svc
.
URN
(),
c
.
Urls
,
cli
)},
},
nil
}
type
pythonPackagesSource
struct
{
client
*
pypi.
Client
}
var
_
packagesSource
=
&
pythonPackagesSource
{}
func
(
s
*
pythonPackagesSource
)
Get
(
ctx
context.
Context
,
name
reposource.
PackageName
,
version
string
) (reposource.
VersionedPackage
,
error
) {
_
,
err
:=
s
.
client
.
Version
(
ctx
,
name
,
version
)
if
err
!=
nil
{
return
nil
,
err
}
return
reposource
.
NewPythonVersionedPackage
(
name
,
version
),
nil
}
func
(
pythonPackagesSource
)
ParseVersionedPackageFromConfiguration
(
dep
string
) (reposource.
VersionedPackage
,
error
) {
return
reposource
.
ParseVersionedPackage
(
dep
)
}
func
(
pythonPackagesSource
)
ParsePackageFromName
(
name
reposource.
PackageName
) (reposource.
Package
,
error
) {
return
reposource
.
ParsePythonPackageFromName
(
name
)
}
func
(
pythonPackagesSource
)
ParsePackageFromRepoName
(
repoName
api.
RepoName
) (reposource.
Package
,
error
) {
return
reposource
.
ParsePythonPackageFromRepoName
(
repoName
)
}
Back
|
FazBrowse Home
|
New Git URL