Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
deanishe committed Dec 29, 2014
0 parents commit 6447bc9
Show file tree
Hide file tree
Showing 181 changed files with 25,571 additions and 0 deletions.
Binary file added Fakum-1.0.alfredworkflow
Binary file not shown.
21 changes: 21 additions & 0 deletions LICENCE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2014 Dean Jackson <[email protected]>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
119 changes: 119 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
# Alfred Fakum #

Generate fake test data in Alfred for testing.

![][demo]

## Download ##

Get the workflow from [GitHub][gh-releases] or [Packal][packal].

## Usage ##

- `fake [<query>]` — List/filter available fake data types
- ``, `⌘+C` or `⌘+NUM` — Copy one fake datum to clipboard
- `⌘+↩` — Paste fake datum into frontmost app
- `` — Specify number of datasets to copy to clipboard
- `⌘+L` — Show generated data in Alfred's Large Text window
- `fakeconfig [<query>]` — Activate and deactivate locales for fake data
- `` — Toggle selected locale on or off

If you specify multiple data, e.g. `fake Name ⟩ 10` for 10 names, the data
will be separated by newlines (`\n`).

In the case of `Paragraph` and `Address` types, the data will be separated
by two newlines (`\n\n`).

## Supported data types ##

| Name | Example |
|-- |--|
| Name | Arabella Hahn-Matthäi |
| First Name | Jeffrey |
| Last Name | Renner |
| Email | [email protected] |
| Email (corporate) | [email protected] |
| Email (free) | [email protected] |
| Email (safe) | [email protected] |
| Email domain (free) | hotmail.com |
| Address | Ronda de Claudia Alegre 9<br>Melilla, 57359 |
| Street | Paseo Lila Roca 52 |
| Street Name | Cuesta Mauricio Sotelo |
| City | León |
| State | Vizcaya |
| State abbr. | WA |
| Country | Albanien |
| TLD | de |
| Domain Name | ankunding.org |
| Domain Word | tormo-vazquez |
| IP Address (IPv4) | 23.1.170.203 |
| IP Address (IPv6) | 9144:9c8a:e1b3:db99:df20:be35:8fd0:1ab2 |
| URI | http://cummerata-kuvalis.com/app/category/register.php |
| URI path | tags |
| URL | http://pollich-rath.com/ |
| Corporate BS | revolutionize virtual e-markets |
| Corporate catchphrase | Optional executive leverage |
| Company | Löwer AG |
| Company suffix | LLC |
| Paragraph | Error culpa amet voluptatem et delectus labore. Facilis deserunt quae aliquid mollitia. Aut esse qui totam dolor consequatur dolorem. |
| Sentence | Provident vel quod dolorem in. |
| Word | sint |
| Date | 1985-05-14 |
| Datetime | 1981-01-28 14:37:06 |
| ISO 8601 Datetime | 1990-07-30T08:41:53 |
| Time | 00:42:12 |
| Timezone | Europe/Istanbul |
| UNIX timestamp | 261754578 |


## Supported locales ##

**Note**: Not all locales support all data types.

- Bulgarian
- Czech
- German
- Danish
- Greek
- English (CA)
- English (GB)
- English (US)
- Spanish (ES)
- Spanish (MX)
- Persian
- Finnish
- French
- Hindi
- Italian
- Korean
- Lithuanian
- Latvian
- Dutch
- Norwegian
- Polish
- Portuguese (BR)
- Russian
- Slovenian
- Chinese (CN)
- Chinese (TW)

## Licensing, thanks ##

Icons are from [Font Awesome][font-awesome] ([SIL OFL 1.1 Licence][sil]).

Alfred Fakum uses the following libraries:

- [Faker][faker] ([licence][faker-licence])
- [docopt][docopt] ([MIT Licence][mit])
- [Alfred-Workflow][alfred-workflow] ([MIT Licence][mit])

[gh-releases]: https://github.com/deanishe/alfred-fakeum/releases
[packal]: http://www.packal.org/workflow/fakeum
[mit]: http://opensource.org/licenses/MIT
[alfred-workflow]: http://www.deanishe.net/alfred-workflow/
[font-awesome]: http://fortawesome.github.io/Font-Awesome/
[docopt]: http://docopt.org/
[faker]: http://www.joke2k.net/faker/
[faker-licence]: https://github.com/joke2k/faker/blob/master/LICENSE.txt
[sil]: http://scripts.sil.org/OFL
[demo]: demo.gif
Binary file added demo.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
38 changes: 38 additions & 0 deletions extra/example_data.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/usr/bin/env python
# encoding: utf-8
#
# Copyright © 2014 [email protected]
#
# MIT Licence. See http://opensource.org/licenses/MIT
#
# Created on 2014-12-29
#

"""
"""

from __future__ import print_function, unicode_literals, absolute_import

import sys
import os

sys.path.insert(0, os.path.join(os.path.dirname(os.path.dirname(__file__)),
'src'))

from workflow import Workflow

import fakum


def main():
wf = Workflow()
fakum.wf = wf
print(' | Name | Example |')
print(' |-- |--|')
for name in fakum.FAKERS:
ex = fakum.get_fake_datum(name)
print('| {} | {} |'.format(name, ex).encode('utf-8'))


if __name__ == '__main__':
sys.exit(main())
69 changes: 69 additions & 0 deletions extra/locale_list.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
#!/usr/bin/env python
# encoding: utf-8
#
# Copyright © 2014 [email protected]
#
# MIT Licence. See http://opensource.org/licenses/MIT
#
# Created on 2014-12-29
#

"""
Generate a list of locales supported by Faker
"""

from __future__ import print_function, unicode_literals, absolute_import

from pprint import pprint
import re
import sys
import os

dirpath = os.path.join(os.path.dirname(os.path.dirname(__file__)),
'src', 'faker', 'providers')

is_locale = re.compile(r'[a-z]{2}_[A-Z]{2}').match

locale_names = {
'bg_BG': 'Bulgarian',
'cs_CZ': 'Czech',
'de_DE': 'German',
'dk_DK': 'Danish',
'el_GR': 'Greek',
'en_CA': 'English (CA)',
'en_GB': 'English (GB)',
'en_US': 'English (US)',
'es_ES': 'Spanish (ES)',
'es_MX': 'Spanish (MX)',
'fa_IR': 'Persian',
'fi_FI': 'Finnish',
'fr_FR': 'French',
'hi_IN': 'Hindi',
'it_IT': 'Italian',
'ko_KR': 'Korean',
'lt_LT': 'Lithuanian',
'lv_LV': 'Latvian',
'nl_NL': 'Dutch',
'no_NO': 'Norwegian',
'pl_PL': 'Polish',
'pt_BR': 'Portuguese (BR)',
'ru_RU': 'Russian',
'sl_SI': 'Slovenian',
'zh_CN': 'Chinese (CN)',
'zh_TW': 'Chinese (TW)',
}


def main():
locales = {}
for filename in os.listdir(dirpath):
path = os.path.join(dirpath, filename)
if not os.path.isdir(path) or not is_locale(filename):
continue
locales[filename] = locale_names.get(filename, '')

pprint(locales)


if __name__ == '__main__':
sys.exit(main())
Binary file added src/active.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
89 changes: 89 additions & 0 deletions src/config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
#!/usr/bin/python
# encoding: utf-8
#
# Copyright © 2014 [email protected]
#
# MIT Licence. See http://opensource.org/licenses/MIT
#
# Created on 2014-12-29
#

"""config.py [options] [args]
Usage:
config.py --toggle <locale>
config.py <query>
Options:
--toggle <locale> Turn locale on/off
-h, --help Show this help message
"""

from __future__ import print_function, unicode_literals, absolute_import


import subprocess
import sys

from workflow import Workflow
from fakum import ALL_LOCALES, DEFAULT_SETTINGS, UPDATE_SETTINGS, HELP_URL

ALFRED_AS = 'tell application "Alfred 2" to search "fakeconfig "'

log = None


def main(wf):
from docopt import docopt
args = docopt(__doc__, wf.args)

log.debug('args : {!r}'.format(args))

if args.get('--toggle'):
loc = args.get('--toggle')
active = wf.settings.get('locales', [])
is_active = loc in active

if is_active:
msg = 'Deactivated locale {}'.format(ALL_LOCALES.get(loc))
active.remove(loc)
wf.settings['locales'] = active
else:
msg = 'Activated locale {}'.format(ALL_LOCALES.get(loc))
active.append(loc)
wf.settings['locales'] = active

log.info(msg)
print(msg)

subprocess.call(['osascript', '-e', ALFRED_AS])
return 0

query = args.get('<query>')

locales = sorted([(v, k) for (k, v) in ALL_LOCALES.items()])

if query:

locales = wf.filter(query, locales, key=lambda t: '{} {}'.format(*t),
min_score=30)

for name, loc in locales:
if loc in wf.settings.get('locales', []):
icon = 'active.png'
else:
icon = 'inactive.png'
wf.add_item(name, loc,
arg=loc,
valid=True,
icon=icon)

wf.send_feedback()


if __name__ == '__main__':
wf = Workflow(default_settings=DEFAULT_SETTINGS,
update_settings=UPDATE_SETTINGS,
help_url=HELP_URL)
log = wf.logger
sys.exit(wf.run(main))
Loading

0 comments on commit 6447bc9

Please sign in to comment.