semvec/pypi-packages huggingface dataset:
py_unpack_sourcemap 1.0.1
Unpack JavaScript source maps into source files
License: MIT
Requires Python: >=3.10,<4.0
Keywords: sourcemaps

# py_unpack_sourcemap

Unpack JavaScript source maps into source files

[![PyPI - Version](https://img.shields.io/pypi/v/py_unpack_sourcemap)][PyPI]
[![PyPI - Downloads](https://img.shields.io/pypi/dm/py_unpack_sourcemap)][PyPI]
[![PyPI - Status](https://img.shields.io/pypi/status/py_unpack_sourcemap)][PyPI]
[![License](https://img.shields.io/github/license/lonelyteapot/py_unpack_sourcemap)][GitHub]

## Description

This Python tool allows you to extract JavaScript source files from source maps.
It can be particularly useful for debugging and analyzing minified JavaScript
code in production environments.

Modern browsers like Chrome and Firefox provide this functionality in DevTools.
However, they only let you view the source code in the browser itself, which can
be limiting. This tool allows you to extract the whole source tree for viewing
it in your favourite IDE.

This projects aims to follow the
[Source Map Revision 3 Proposal](https://sourcemaps.info/spec.html).
Only the `sourcesContent` field is currently supported.
See [Roadmap](#roadmap) for what is lacking.

## Installation

Ensure you have Python 3.10 or later installed.
The package is not tested on older versions, but they will probably work.

You can install the tool from [PyPI] using pip:

```sh
pip install py_unpack_sourcemap
```

Or [Poetry]:

```sh
poetry add py_unpack_sourcemap
```

## Usage

### As a command-line tool

```
python -m py_unpack_sourcemap [-h] -o OUTPUT_DIR [--overwrite] sourcemap

positional arguments:
  sourcemap             path to the source map (a .js.map file)

options:
  -h, --help            show this help message and exit
  -o OUTPUT_DIR, --output-dir OUTPUT_DIR
                        a directory to extract source files into
  --overwrite           overwrite existing output directory
```

### As a Python module

> No information here yet :( Use autocompletion or view the source code.

## Roadmap

This project is developed on demand.
If you need a feature, [submit an issue][new issue] to express your interest.

- [ ] Support for fetching remote source maps via HTTP
- [ ] Support for `null` elements in `sourcesContent` field
- [ ] More tests
- [ ] Support for `sourceRoot` field
- [ ] Support for `names` field
- [ ] Support for `mappings` field
- [ ] "Index map" format (`sections` field)
- [ ] GitHub workflows for tests and publishing

[//]: # "when editing, please remove entries instead of checking them off"

## Contributing

Any contributions are appreciated. Regular stuff.
Don't be afraid to submit issues or PRs.

## Contributors

- [lonelyteapot](https://github.com/lonelyteapot) - original author

## License

This project is licensed under the [MIT License](https://mit-license.org/).

[GitHub]: https://github.com/lonelyteapot/py_unpack_sourcemap
[new issue]: https://github.com/lonelyteapot/py_unpack_sourcemap/issues/new
[PyPI]: https://pypi.org/project/py_unpack_sourcemap/
[Poetry]: https://python-poetry.org/
a-pandas-ex-bs4df 0.12
One-line-web-scraping by combining pandas and BeautifulSoup4
License: MIT
Keywords: BeautifulSoup4,bs4,pandas,web scraping


### One line web scraping by combining pandas and BeautifulSoup4

##### Check out the video

<div align="left">
      <a href="https://www.youtube.com/watch?v=pvnODvnMyrg">
         <img src="https://img.youtube.com/vi/pvnODvnMyrg/0.jpg" style="width:100%;">
      </a>
</div>

##### Code from the video

```python
pip install a-pandas-ex-bs4df 
```

```python
from a_pandas_ex_bs4df import pd_add_bs4_to_df
import pandas as pd
pd_add_bs4_to_df()    

from PrettyColorPrinter import add_printer #optional
add_printer(True) #optional

df=pd.Q_bs4_to_df(r'https://github.com/search?l=Python&q=python&type=Repositories')
df.loc[(~df.bb_href.isna()) & df.aa_attrs_values.str.contains('middle',regex=False, na=False)]
df.loc[(~df.bb_href.isna()) & df.aa_attrs_values.str.contains('middle',regex=False, na=False)].ff_fetchParents.apply(lambda x: x())
df.loc[(~df.bb_src.isna()) & (~df.bb_src.str.contains(r'\.png$',regex=True,na=False))]
df.loc[(~df.bb_src.isna()) & (df.bb_src.str.contains(r'\.png$',regex=True,na=False))]
```

```python
Parameters:
    htmlcode:Union[str,bytes]
        file path, url or html source code
        urls will be downloaded with requests
    dontuse:tuple
        bs4 attributes to exclude from the dataframe
        default = (
        "element_classes",
        "builder",
        "is_xml",
        "known_xml",
        "_namespaces",
        "parse_only",
        "markup",
        "contains_replacement_characters",
        "original_encoding",
        "declared_html_encoding",
        "parser_class",
        "namespace",
        "prefix",
        "cdata_list_attributes",
        "preserve_whitespace_tag_stack",
        "open_tag_counter",
        "preserve_whitespace_tags",
        "interesting_string_types",
        "current_data",
        "string_container_stack",
        "_most_recent_element",
        "currentTag",
    )
    parser: str
        Have a look at the bs4 documentation
        (default='lxml')
    tags_to_find:Union[bool,str]=True
        will be passed to soup.find_all()
        Have a look at the bs4 documentation
        (default=True) #everything
Returns:
    df: pd.DataFrame
```