Giter VIP home page Giter VIP logo

randomname's Introduction

randomname

Generate random unique ids using real words - like docker containers or github repos.

Often, I get tired of trying to hunt down files in folders differentiated by some numeric id, and unless I need to encode a timestep into the name, I'd rather use an id that's memorable and easy to type.

The wordlists are graciously sourced from: https://github.com/imsky/wordlists

NOTICE: If you come across any words in these wordlists that are offensive, pleaseplspls report them to me in an issue! Any of these word lists used come from external sources and there are lots of words.

Install

pip install randomname

Usage

# get adj-noun:
$ randomname get
# sleek-voxel
$ randomname get
# frayed-potentiality
$ randomname get
# recursive-vector
$ randomname get
# convoluted-peninsula

# specify adj-noun sub-categories (respectively):
$ randomname get weather shopping,cats
# freezing-store

# or define your own format:
$ randomname generate adj/sound n/apex_predators
# blaring-crocodile

# use multiple categories:
$ randomname generate v/art,v/thought a/sound n/apex_predators
# doodle-silent-salamander

# mix in your own words (e.g. "cat"):
$ randomname generate v/fire a/music_theory n/cats cat
# toast-adagio-angora-cat

The lists include various word classes:

  • adjectives (a, adj) - ya know those describe-y things
    • e.g. a/colors, adj/shape, adjectives/sound
  • nouns (n, nn) - people, places, things dawg
    • e.g. n/cats, nn/ghosts, nouns/wine
  • verbs (v, vb) - doing things
    • e.g. v/art, vb/3d_graphics
  • names (nm) - things like surnames, streets, cities, etc.
    • e.g. nm/cities, names/codenames
  • ipsum (ip) - misc.
    • e.g. ip/reddit, ipsum/blockchain

It's importable too!

import randomname

# generate name using all categories
name = randomname.get_name()
# or specify a subset of the categories
name = randomname.get_name(adj=('music_theory',), noun=('cats', 'food'))
# or - you can take a bit more liberty about
name = randomname.generate(
    'v/fire', 'adj/music_theory', ('n/cats', 'n/food'))

# these contain the available groups
print('adjective categories:', randomname.ADJECTIVES)
print('noun categories:', randomname.NOUNS)

Available

adjectives:

speed, weather, shape, sound, physics, temperature, corporate_prefixes, complexity, colors, taste, quantity, size, algorithms, geometry, materials, construction, music_theory, appearance, linguistics, emotions, age, character

nouns:

accounting, fortifications, typography, spirits, cotton, car_parts, shopping, chemistry, seasonings, gaming, cats, real_estate, wood, military_navy, wine, music_production, sports, meat, physics, physics_waves, corporate, web_development, condiments, design, automobiles, metals, fast_food, radio, physics_units, military_airforce, 3d_printing, 3d_graphics, travel, dogs, houses, astronomy, buildings, minerals, startups, algorithms, fruit, apex_predators, infrastructure, geometry, set_theory, ghosts, military_army, music_instruments, filmmaking, birds, construction, music_theory, corporate_job, driving, linear_algebra, fish, coding, architecture, writing, phones, machine_learning, furniture, history, plants, cheese, food, containers, vcs, water, storage, geography, physics_optics, data_structures, screenwriting, insurance

verbs:

graphics, movement, music, cooking, thought, military_navy, music_production, manipulation, sports, corporate, creation, destruction, quantity, radio, 3d_graphics, look, fire, collection, programming, art, driving, vcs, communication, web

ipsum:

corporate, hipster, blockchain, lorem, reddit

Examples

extremal-cluster, cerulean-portal, afraid-cabana, forward-segment, angry-croissant, coffee-shore, binding-frontlist, nondeterministic-wall, cool-quail, optical-valid, ornery-solenoid, immense-aside, square-loan, fast-limiter, wicker-tritone, white-commander, wan-flam, violent-slider, isothermal-lark, seething-luggage, resolving-section, steel-snippet, shortest-linkage, oscillating-palisade, tense-nailer, adjacent-sea, mechanical-molding, cold-feed, either-scene, crazy-boundary, simple-bass, roaring-annuity, paper-melt, scared-angle, shiny-hydrolysis, ornery-pretzel, brute-force-keel, worn-cliff, brownian-contingency, naive-shop, heartless-object, bronze-microphone, universal-yeoman, icy-reflection, blue-cliche, forward-integrator, trusting-cobra, online-assignment, religious-gun, quiet-hook, blaring-quaver, archaic-height, eager-oboe, leather-narrator, shortest-bucket, free-matrix, radioactive-loss, glossy-take, formal-schema, quantum-agreement, local-bit, bone-centroid, cyan-resin, mild-chimpanzee, mute-bugle, amiable-margin, basic-pond, humane-tangerine, horizontal-bocaccio, big-export, pleasant-facet, fixed-glass, muffled-futon, volumetric-simulation, piercing-skier, pleasant-observatory, honest-hound, cross-recon, future-surface, ash-crew, medium-stunt, latent-mayonnaise, nippy-valance, open-gate, crazy-papaya, khaki-bat, honest-melon, congruent-truss, express-flat, glad-simulation, sizzling-parakeet, interior-pantone, coplanar-gully, merciless-mud, direct-asadero, several-jackdaw, wide-agent, fixed-heather, kind-slab, genteel-designer

randomname's People

Contributors

beasteers avatar luismavs avatar oborichkin avatar wochinge avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

randomname's Issues

Enforce exactly two words in randomname.get_name

The command randomname.get_name() returns a string of the form abcd-efgh more than 99% of the time.
But, sometimes it returns a string of the form abcd-efgh-ijkl. This can break some fragile workflows.

There are exactly two offending lines for the adj-noun recipe:
https://github.com/imsky/wordlists/blob/b26782e929a288d55fae6f507760291b9367418d/nouns/food.txt#L40
https://github.com/imsky/wordlists/blob/cfee5df781890de614e8f634ed49ad853116ed35/adjectives/algorithms.txt#L20

I don't know whether it makes sense to ask for the change in the upstream repo, or to fix it here.

feature: pass max length for resulting name

I would like to use names to label pattern recognition results, and would like to fit names into a fixed-width numpy recarray field. I can write a wrapper to repick until a name meets the length criteria, but would be nice if the api supported this functionality (and possibly more efficient if the lists themselves allowed drawing by length).

Thanks for this package!

Add ability to blacklist certain words

I'm sure there are words that people don't like/don't want to show up. We should allow users to exclude certain words, or patterns. Perhaps even just having filters that allow arbitrary exclusions (no words with more than 9 characters?) idk

docssssssss

Need to add sphinx rtd setup now that people are actually using it so they know how to use the interface

Ability to define a new delimiter?

Would be suuuper nice to be able to change between other delimiters...like _ , ; : etc.
So an option flag...
randomname generate adj/ noun/ --delim=_
If you're busy I can probably work up a PR for it :)

Crash when using randomname in application packed with PyInstaller

Overview

Operating System: Windows 11 64 bit
PyInstaller Version: 4.8
Python Version: 3.8.5
Version of randomname:

> pip show randomname
Name: randomname
Version: 0.1.5
Summary: Generate random adj-noun names like docker and github.
Home-page: https://github.com/beasteers/randomname
Author: Bea Steers
Author-email: [email protected]
License: MIT License
Location: c:\users\sebastian\.conda\envs\editor\lib\site-packages
Requires: fire
Required-by:

Issue description

I have an application which uses randomname to create random file names.
The application is packaged into a .exe in Windows using PyInstaller.
When I run the application (as exe) I observe an application crash.

Steps to reproduce:

I have described the steps to reproduce the issue in this this git repository together with the source code, environment and pyinstaller packaging script.

What's the expected result?

Using the application I provided in this git repository I would expect the output to be something like this:

The name is natural-kitchen

If I run the file main.py using python like this

python main.py

I do in fact get the desired output.

What's the actual result?

When I run the application (as exe) I observe an application crash. The console output is:

  File "site-packages\randomname\core.py", line 13, in get_name
  File "site-packages\randomname\core.py", line 7, in generate
  File "site-packages\randomname\core.py", line 8, in <genexpr>
  File "site-packages\randomname\util.py", line 208, in choose
  File "random.py", line 290, in choice

Additional details / screenshot

Screenshot 2022-01-29 190726

Windows compatibility

Hi @beasteers ,

thanks for putting up this library ๐Ÿ’ฏ

We at Rasa ran into some issues using randomname in Windows as Windows uses different path separators than Unix based systems. We should probably rather use os.sep.

We ran into this error on Windows. We use the generated name as part of a filename and the generated name basically leads to an error then.

2021-09-22T16:07:05.6385808Z 
2021-09-22T16:07:05.6386472Z self = <[AttributeError("'GzipFile' object has no attribute 'fileobj'") raised in repr()] GzipFile object at 0x2949e0733c8>
2021-09-22T16:07:05.6387698Z filename = WindowsPath('C:/Users/runneradmin/AppData/Local/Temp/pytest-of-runneradmin/pytest-0/popen-gw0/test_train_skip_on_model_not_changed0/models/20210922-160500_a')
2021-09-22T16:07:05.6388736Z mode = 'rb', compresslevel = 9, fileobj = None, mtime = None
2021-09-22T16:07:05.6389110Z 
2021-09-22T16:07:05.6389511Z     def __init__(self, filename=None, mode=None,
2021-09-22T16:07:05.6390122Z                  compresslevel=9, fileobj=None, mtime=None):
2021-09-22T16:07:05.6390708Z         """Constructor for the GzipFile class.
2021-09-22T16:07:05.6391124Z     
2021-09-22T16:07:05.6391578Z         At least one of fileobj and filename must be given a
2021-09-22T16:07:05.6392098Z         non-trivial value.
2021-09-22T16:07:05.6392442Z     
2021-09-22T16:07:05.6392938Z         The new class instance is based on fileobj, which can be a regular
2021-09-22T16:07:05.6393715Z         file, an io.BytesIO object, or any other object which simulates a file.
2021-09-22T16:07:05.6394429Z         It defaults to None, in which case filename is opened to provide
2021-09-22T16:07:05.6394961Z         a file object.
2021-09-22T16:07:05.6395300Z     
2021-09-22T16:07:05.6395772Z         When fileobj is not None, the filename argument is only used to be
2021-09-22T16:07:05.6396456Z         included in the gzip file header, which may include the original
2021-09-22T16:07:05.6397170Z         filename of the uncompressed file.  It defaults to the filename of
2021-09-22T16:07:05.6397928Z         fileobj, if discernible; otherwise, it defaults to the empty string,
2021-09-22T16:07:05.6398658Z         and in this case the original filename is not included in the header.
2021-09-22T16:07:05.6399159Z     
2021-09-22T16:07:05.6399603Z         The mode argument can be any of 'r', 'rb', 'a', 'ab', 'w', 'wb', 'x', or
2021-09-22T16:07:05.6400256Z         'xb' depending on whether the file will be read or written.  The default
2021-09-22T16:07:05.6401190Z         is the mode of fileobj if discernible; otherwise, the default is 'rb'.
2021-09-22T16:07:05.6401919Z         A mode of 'r' is equivalent to one of 'rb', and similarly for 'w' and
2021-09-22T16:07:05.6402452Z         'wb', 'a' and 'ab', and 'x' and 'xb'.
2021-09-22T16:07:05.6402862Z     
2021-09-22T16:07:05.6427124Z         The compresslevel argument is an integer from 0 to 9 controlling the
2021-09-22T16:07:05.6428071Z         level of compression; 1 is fastest and produces the least compression,
2021-09-22T16:07:05.6428904Z         and 9 is slowest and produces the most compression. 0 is no compression
2021-09-22T16:07:05.6434135Z         at all. The default is 9.
2021-09-22T16:07:05.6434799Z     
2021-09-22T16:07:05.6435322Z         The mtime argument is an optional numeric timestamp to be written
2021-09-22T16:07:05.6436097Z         to the last modification time field in the stream when compressing.
2021-09-22T16:07:05.6436800Z         If omitted or None, the current time is used.
2021-09-22T16:07:05.6437262Z     
2021-09-22T16:07:05.6437602Z         """
2021-09-22T16:07:05.6437938Z     
2021-09-22T16:07:05.6438333Z         if mode and ('t' in mode or 'U' in mode):
2021-09-22T16:07:05.6438944Z             raise ValueError("Invalid mode: {!r}".format(mode))
2021-09-22T16:07:05.6439569Z         if mode and 'b' not in mode:
2021-09-22T16:07:05.6440006Z             mode += 'b'
2021-09-22T16:07:05.6440420Z         if fileobj is None:
2021-09-22T16:07:05.6441038Z >           fileobj = self.myfileobj = builtins.open(filename, mode or 'rb')
2021-09-22T16:07:05.6442494Z E           PermissionError: [Errno 13] Permission denied: 'C:\\Users\\runneradmin\\AppData\\Local\\Temp\\pytest-of-runneradmin\\pytest-0\\popen-gw0\\test_train_skip_on_model_not_changed0\\models\\20210922-160500_a'
2021-09-22T16:07:05.6443411Z 

Happy to put up a PR and maybe a small GitHub actions (it's free on OpenSource) based CI for Linux / Ubuntu if you want?

Add ability to expand to other word lists

It'd be nice, say if someone had a word corpus of their own, to be able do register them

import randomname

# add from file
randomname.register('my/directory/of/lists')  # recursively find .txt files
randomname.register('my/directory/of/lists', ext=['.txt', '.list', '.blah'])  # add your extensions
randomname.register('my/directory/of/lists', loader=lambda f: open(f, 'r').split(','))  # custom loader? idk

# add literal lists
randomname.register({
    'nouns/things': ['something', 'nothing', ...]
})

I think doing this might benefit from some refactoring, but we'll see. I definitely don't want to over-complicate this project.

Specific sources to potentially parse and include:

feature: pass in seed for repeatability

I would like to get the same name repeatably for - say - an integer. Could the package accept a seed? Setting a seed globally may also be useful for testing.

Thank you for the package!

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.