Metadata-Version: 2.4
Name: fetch-cpy-src
Version: 0.1.2
Summary: Fetch selected part of cpython source repository.
Author: Alfred DU
Author-email: ihearmywords@hotmail.com
Requires-Python: >=3.10, <4
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Requires-Dist: click (>=8.3.0,<9.0.0)
Requires-Dist: pygithub (>=2.6.1,<3.0.0)
Requires-Dist: requests (>=2.32.3,<3.0.0)
Requires-Dist: tomli (>=2.2.1,<3.0.0)
Description-Content-Type: text/markdown

# Fetch selected part of cpython source repository.

This project is part of [`phy`](https://github.com/phy-precompiler).

## Install

```shell
pip install fetch-cpy-src
```


## List the files to be fetched 

Make a manifest toml file with scheme like the following example:

```toml
# git repo tag
tag = "3.12"


# Specify items of source to fetch.

# This is a demo item specification for fetch single file of source repo.
#
# There are two REQUIRED fields:
# `path`: path of the file to be fetched;
# `type`: set to "file" for fetching single file.
[[items]]
path = 'Parser/asdl_c.py'
type = 'file'

# `rename` is OPTIONAL. Specifying this field can rename fetched file or move to 
# another directory.
rename = 'asdl_c.py'

# The `xxx_adapters` are OPTIONAL fields. Adapters will make pre-defined modification
# to fetched source files. 
#
#  + `file_adapters` will apply modification to fetch file (if type = 'file') or 
#    any files within fetched directory (if type = 'dir').
#  + `dir_adapters` will apply modification to the directory of the fetched file 
#    (if type = 'file') or the fetched directory (if type = 'dir').
# 
# In this example, 
#  + `TopLevelScriptImportAdapter` will refactor the fetched python script file to 
#    importable submodules.
#  + `AddDunderInitAdapter` will put an empty `__init__.py` at fetched directory, 
#    and thus make it a package.
file_adapters = ['TopLevelScriptImportAdapter']
dir_adapters = ['AddDunderInitAdapter']


# This is a demo item specification for fetch sub-directory of source repo.
# `path`: path of the directory to be fetched;
# `type`: set to "dir" for fetching entire sub-directory.
[[items]]
path = 'Grammar/'
type = 'dir'

```

## Fetch files 

Supposing the manifest file is `demo.toml`, fetch the files within the manifest by 
this command: 

```shell
fetch-cpy-src fetch demo.toml
```

The full manual of the `fetch-cpy-src` command:

```shell
Usage: fetch-cpy-src [OPTIONS] COMMAND [ARGS]...

  group all sub commands

Options:
  --help  Show this message and exit.

Commands:
  fetch         Fetch files listed in manifest to destinition directory.
  new-manifest  Create a new manifest of cpython source files to be fetched.
```

# API docs

+ [module](docs/module.md)
+ [manifest](docs/manifest.md)
+ [adapter](docs/adapter.md)

