Git Product home page Git Product logo

d8s-file-system's People

Contributors

fhightower avatar

Stargazers

 avatar

Watchers

 avatar  avatar

d8s-file-system's Issues

Improve how failures are handled by the directory_files_read function

What?

Currently, if the directory_files_read function is unable to read one file in a directory, it raises an exception and does so in a way that is difficult to handle.

For example, let's say there are four files in a directory and the directory_files_read reads the first two correctly but fails with a UnicodeDecodeError on the third:

for path, contents in directory_files_read(directory_path, recursive=False):
    ...

There is no good way I'm aware of to handle this failure in a way that would let you skip the error and move on.

How?

I believe the best solution is to add error handling into this function.

ERROR: No matching distribution found for democritus_file_system

Context

Python version (e.g. 3.9.1): 3.10.9
Version of this project being used (e.g. 1.2021.01.13): Last version via pip.
Other info (if applicable): N/A

What I did

I tried installing democritus_file_system because it's in the requirements_dev.txt of the html-to-json project, but I'm getting an error that breaks the installation:

$ pip --version
pip 23.0
$ pip install -r requirements_dev.txt 
Collecting black
  Using cached black-23.1.0-py3-none-any.whl (174 kB)
Collecting bump2version
  Using cached bump2version-1.0.1-py2.py3-none-any.whl (22 kB)
Collecting codecov
  Using cached codecov-2.1.12-py2.py3-none-any.whl (16 kB)
Collecting democritus_file_system
  Using cached democritus_file_system-2021.1.2701.tar.gz (12 kB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
Discarding https://files.pythonhosted.org/packages/fb/3d/191c46b705d7b9fbce09f09ae10e7f8aa1f635bb5dbc75ae5702c207fa8c/democritus_file_system-2021.1.2701.tar.gz (from https://pypi.org/simple/democritus-file-system/): Requested democritus_file_system from https://files.pythonhosted.org/packages/fb/3d/191c46b705d7b9fbce09f09ae10e7f8aa1f635bb5dbc75ae5702c207fa8c/democritus_file_system-2021.1.2701.tar.gz (from -r requirements_dev.txt (line 4)) has inconsistent version: expected '2021.1.2701', but metadata has '2021.1.27'
  Using cached democritus_file_system-2021.1.2101.tar.gz (12 kB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
Discarding https://files.pythonhosted.org/packages/9e/b4/8e1126961c5bf794e5477541c45b08608a160b8211cb31108918df8050ff/democritus_file_system-2021.1.2101.tar.gz (from https://pypi.org/simple/democritus-file-system/): Requested democritus_file_system from https://files.pythonhosted.org/packages/9e/b4/8e1126961c5bf794e5477541c45b08608a160b8211cb31108918df8050ff/democritus_file_system-2021.1.2101.tar.gz (from -r requirements_dev.txt (line 4)) has inconsistent version: expected '2021.1.2101', but metadata has '2021.1.21'
ERROR: Could not find a version that satisfies the requirement democritus_file_system (from versions: 2021.1.2101, 2021.1.2701)
ERROR: No matching distribution found for democritus_file_system

What I expected to happen

I expected the installation of democritus_file_system not to fail.

What actually happened

I've isolated the error messages from the installation of this package, by trying to install it separately:

$ pip install democritus_file_system
Collecting democritus_file_system
  Using cached democritus_file_system-2021.1.2701.tar.gz (12 kB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
Discarding https://files.pythonhosted.org/packages/fb/3d/191c46b705d7b9fbce09f09ae10e7f8aa1f635bb5dbc75ae5702c207fa8c/democritus_file_system-2021.1.2701.tar.gz (from https://pypi.org/simple/democritus-file-system/): Requested democritus_file_system from https://files.pythonhosted.org/packages/fb/3d/191c46b705d7b9fbce09f09ae10e7f8aa1f635bb5dbc75ae5702c207fa8c/democritus_file_system-2021.1.2701.tar.gz has inconsistent version: expected '2021.1.2701', but metadata has '2021.1.27'
  Using cached democritus_file_system-2021.1.2101.tar.gz (12 kB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
Discarding https://files.pythonhosted.org/packages/9e/b4/8e1126961c5bf794e5477541c45b08608a160b8211cb31108918df8050ff/democritus_file_system-2021.1.2101.tar.gz (from https://pypi.org/simple/democritus-file-system/): Requested democritus_file_system from https://files.pythonhosted.org/packages/9e/b4/8e1126961c5bf794e5477541c45b08608a160b8211cb31108918df8050ff/democritus_file_system-2021.1.2101.tar.gz has inconsistent version: expected '2021.1.2101', but metadata has '2021.1.21'
ERROR: Could not find a version that satisfies the requirement democritus_file_system (from versions: 2021.1.2101, 2021.1.2701)
ERROR: No matching distribution found for democritus_file_system

Other details

N/A.

I don't have much clues as to why this fails. Any help is appreciated, thanks !

Write function to replace given text in all files in a given directory

What?

(See issue title)

Why?

This is a common use-case that would be helpful to have.

How?

I recommend writing a function with the following signature:

def directory_replace_text_in_files(directory_path: str, old: str, new: str, *, recursive: bool = False) -> Iterator[str]:
    ...

For the directory path, it would be nice to accept a Pathlib.Path or str. The function should yield file_paths that were updated.

Consider using flags to specify whether path or name is returned

For example, rather than having directory_subdirectory_names and directory_subdirectory_paths, simply have directory_subdirectories(dir_path: str, return_paths: bool = False) where the return_paths flag determines whether the returned items are paths or file names.

This would involve consolidating and simplifying the code and interfaces in this library.

This ticket also involves changing the function calls in all of the democritus libraries that use these functions.

Add function to remove file ending from file name

HELP WANTED ๐Ÿ‘‹ : If you'd like to take this challenge on, please let me know! Even if you're new to Python and/or github, this is a great place to start and I'd be happy to help walk you through this challenge as much as you need - don't hesitate to ask.

This particular issue will give you some exposure to writing a relatively simple function, working with strings in Python, and writing some tests.


We already have a file_extension function to find a file extension. Now, we'd like to have a function which, given a file name (e.g. foo.py), returns the file name without the extension (e.g. foo). I propose the function should be named file_name_strip_extension, but am open to other suggestions.

If you're interested in taking this challenge on, comment on this issue and I'll assign it to you.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.