Just a reminder that we sent you a DM some time ago, but have yet to receive an answer. Happy cake day :)
-The admin team
Just a reminder that we sent you a DM some time ago, but have yet to receive an answer. Happy cake day :)
-The admin team
While we have opened up community creation for users, please refrain from misusing the feature.
Also, as specified in our code of conduct, try to avoid personal attacks. @Lmaydev@programming.dev
Personally I would recommend to use regex instead for parsing, which would also allow you to more easily test your expressions. You could then get the list as
import re
result = re.findall(r'[\w_]+|\S', yourstring) # This will preserve ULLONG_MAX as a single word if that's what you want
As for what’s wrong with your expressions:
First expression: Once you hit (
, OneOrMore(Char(printables))
will take over and continue matching every printable char.
Instead you should use OR (|
) with the alphanumerical first for priority OneOrMore(word | Char(printables))
Second expression. You’re running into the same issue with your use of +
. Once string.punctuation takes over, it will continue matching until it encounters a char that is not a punctuation and then stop the matching.
Instead you can write:
parser = OneOrMore(Word(alphanums) | Word(string.punctuation))
result = parser.parseString(yourstring)
Do note that underscore is considered a punctutation so ULLONG_MAX will be split, not sure if that’s what you want or not.
I don’t have any experience with pipx and personally prefer to just skip the .toml and place the whole pyprojectsetup in setup.py.
With that method, I would write inside setup()
packages=find_packages() # Include every python packages
package_data={ # Specify additional data files
'yourpackagename': [
'config/*'
etc...
]
}
This would however require you to have a package folder which all your package files/folders are inside, meaning the top level repo folder should not have any files or other folders that you want to distribute. Your MANIFEST.in looks fine.
deleted by creator
deleted by creator
You can, but you may need to edit some registers to avoid windows reseting them.
As others have suggested, ffmpeg is a great cli tool. If you aren’t comfortable with the terminal you can do it via python like this:
import os
import sys
import subprocess
def crop_media(file_name: str, w: int, h: int, x: int, y: int, new_dir: str) -> None:
try:
subprocess.run(f'ffmpeg -i "{file_name}" -vf "crop={w}:{h}:{x}:{y}" temp.gif -y',
shell=True, check=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
os.rename('temp.gif', os.path.join(new_dir, file_name))
# Print the error and continue with other gifs, remove try block if you want a complete stop
except subprocess.CalledProcessError as e:
print(e)
except KeyboardInterrupt:
print('KeyboardInterrupt, cleaning up files...')
os.remove('temp.gif')
sys.exit(0)
def crop_directory(directory: str, w: int, h: int, x: int, y: int, new_dir: str) -> None:
for root, _, files in directory:
for file in files:
if not file.endswith('.gif'):
continue
if os.path.isfile(os.path.join(new_dir, file)):
print(f'{file} already exists in {new_dir}, skipping...')
continue
file_path = os.path.normpath(os.path.join(root, file))
crop_media(file_path, w, h, x, y, new_dir)
if __name__ == '__main__':
width = 0
height = 0
x_offset = 0
y_offset = 0
gif_directory = ''
new_directory = ''
crop_directory(gif_directory, width, height, x_offset, y_offset, new_directory)
This should go through every file in the directory and subdirectories and call the ffmpeg command on each .gif. With new_directory
you can set a directory to store every cropped .gif. The ffmpeg command is based on johnpiers suggestion.
The script assumes unique filenames for each gif and should work with spaces in the filenames. If they aren’t unique, you can just remove the new_directory
part, but you will then lose the original gif that you cropped.
But I think that both are useless because you can put what you want in a list in python.
You can say that about all type hinting, but assuming you actually adhere to the type hints, it’s a great tool to make python projects manageable.
You can just run the code in the debugger to see if it does what you expect.
Men can be nasty and intimidating towards women as history have shown a million times. Add in the fact you have a lot of “old fashioned” men in the sport that may not be up to date on how you should behave in the third millennium. If you want to grow the sport, you need to facilitate a safe and welcoming environment for everyone. Tournaments exclusive to girls is one way build towards that.
Chess got an open class and a female class. The latter is there to provide a safer environment for girls and hopefully encourage more to try out the sport.
Also, I’ve yet to see a single Linux kernel that is aesthetically pleasing
Hmm…
Does lemmy have copypasta community?
Wheels is something you use when packaging your module for upload. You will automatically use a wheel package if the module you are downloading was uploaded using wheels and your pc config is compatible with the wheel package.
What wheels does is it pre builds the module for a given system (doesn’t need to be a very specific system) so that you don’t have to do it locally when installing (if you got a compatible config).
It’s not something users have to think about, for them wheel package == smaller and faster install. Pip will by default prioritise wheel package over source.
Taiwan would never attack China, the only way a war between China and Taiwan happens is if China invades Taiwan.
China saying this increases the “risk” of war is nothing but doublespeak.
Guido once said on a podcast that if they ever ended up doing python4, removing the GIL might be one of the reason for that move. He wanted to avoid the issues we got with python2 - > 3 though. I wouldn’t worry too much.
putting thumbnails in the file selection dialog
Could you elaborate what you by this?
Downloads and Documents starting with a capital letter is my biggest pet peeve with Ubuntu. It makes it a lot more annoying to navigate through them than if it was all lower case.
Obviously this is opinionated and I won’t pretend it’s the only correct way, but a few things that stood out to me was.
inconsistent use of type hinting. You type hint the “elem” arg for process_content and nothing else. Personally I use type hints religiously, but at the very least I would type hint every arg. The type may be obvious to you now, but it may not in 6 months, or for others who want to contribute.
while on the topics of type hints, you use “#” to comment the purpose of each function, but you really should use docstrings instead. Text editors supporting python will then use the docstrings to show users the description of each function without you having to jump to the declaration to read the description. It’s particularly useful when you got multiple modules. For some IDEs like pycharm, the same format works on variables too.
You should wrap up your bottom infinite loop in if __name__ == '__main__':
to avoid getting locked if you down the line want to reuse the class/module and import it into another file.
And the most opinionated point of them all:
I assume the setup is the same with GitHub’s ci, but with GitLab you can automate pylint to check the the code with this:
image: python:3.10
script:
- pip install pylint
- pylint *folder*```
From the perspective of the admin team, as long as reports are consistently resolved in a timely manner we are happy.
If you have any questions or want help with finding extra moderators, feel free to ask it here or via DM, otherwise we also have a Discord server and a Matrix space where we can talk.