java-classname-generator

commit 59d3bdacd04b32fe2557a4adada536e9fabe61a3

tree

parent:
ef10801b5d8de820fbb494484c589d17ebbdcf27

Nick Mykins <nick.mykins@gmail.com>

2014-10-18T20:20:15-04:00

put words in yaml

diff --git a/data.yaml b/data.yaml
new file mode 100644
index 0000000000000000000000000000000000000000..47a17cc470f4ce8b5d1e9673bf40f44d41798e81
--- /dev/null
+++ b/data.yaml
@@ -0,0 +1,150 @@
+---
+firsts:
+    - Abstract
+    - AnnotationMethod
+    - Application
+    - Aspect
+    - Base
+    - Configurable
+    - Data
+    - Default
+    - Generic
+    - Mock
+    - Mutable
+    - Namespace
+    - Simple
+    - Sql
+    - Invalid
+    - Internal
+    - Jdbc
+    - Standard
+    - Transaction
+middles:
+    - ContextAware
+    - Frame
+    - Factory
+    - Auto
+    - Meta
+    - PostProcessing
+    - Http
+    - Bound
+    - Element
+    - Pdf
+    - Reflective
+    - Refreshable
+    - Hashable
+    - Regexp
+    - Method
+    - Value
+    - Type
+    - Stateless
+    - Theme
+    - Entry
+    - Window
+    - Config
+    - Session
+    - ASync
+    - Byte
+    - Caching
+    - Char
+    - Array
+    - List
+    - Xml
+    - Streaming
+    - Multipart
+    - Throttle
+    - Parallel
+    - Service
+    - Task
+    - Trigger
+    - Binding
+    - Remote
+    - ToString
+    - Enum
+    - Style
+    - IO
+    - DependsOn
+    - Embedded
+    - Database
+    - Client
+    - Service
+    - Expected
+    - Proxy
+    - Jax
+    - Name
+    - Request
+    - Pooled
+    - Json
+    - Parameterized
+    - NonTransient
+    - Instanceof
+    - ParamAware
+    - Socket
+    - Sequence
+    - Undefined
+    - Loader
+    - Invocation
+    - Timed
+    - Method
+    - MaxValue
+    - MinValue
+    - Url
+    - Resource
+    - Pattern
+    - Help
+    - Entity
+    - Invocation
+    - Extracting
+    - Servlet
+    - Script
+    - ResultSet
+    - Scope
+    - Application
+    - Mail
+    - Throwaway
+    - Connection
+    - Node
+    - Static
+    - Procedure
+    - Labeled
+    - Toolbox
+    - Command
+    - View
+    - Model
+    - Feed
+    - Manual
+lasts:
+    - Logger
+    - Handler
+    - Exception
+    - Adapter
+    - Factory
+    - Bean
+    - Context
+    - Resolver
+    - Detector
+    - Advisor
+    - Interceptor
+    - Translator
+    - PostProcessor
+    - TaskExecutor
+    - Controller
+    - Loader
+    - Module
+    - Scope
+    - Override
+    - Descriptor
+    - Configurer
+    - Utils
+    - Generator
+    - Expression
+    - Wrapper
+    - Chain
+    - Dispatcher
+    - Validator
+    - Literal
+    - Tag
+    - Dao
+    - Daemon
+    - Template
+...
diff --git a/generator.py b/generator.py
index 99da161509743ad6c54d283735dae79b10507762..8e83012605d5b4d9c90a41f5cd0ac79762a08078 100644
--- a/generator.py
+++ b/generator.py
@@ -1,165 +1,23 @@
 from flask import Flask, render_template
 from random import choice, sample
-app = Flask(__name__)
+import yaml
 
-FIRSTS = [
-'Abstract',
-'AnnotationMethod',
-'Application',
-'Aspect',
-'Base',
-'Configurable',
-'Data',
-'Default',
-'Generic',
-'Mock',
-'Mutable',
-'Namespace',
-'Simple',
-'Sql',
-'Invalid',
-'Internal',
-'Jdbc',
-'Standard',
-'Transaction']
-
-MIDDLES = [
-'ContextAware',
-'Frame',
-'Factory',
-'Auto',
-'Meta',
-'PostProcessing',
-'Http',
-'Bound',
-'Element',
-'Pdf',
-'Reflective',
-'Refreshable',
-'Hashable',
-'Regexp',
-'Method',
-'Value',
-'Type',
-'Stateless',
-'Theme',
-'Entry',
-'Window',
-'Config',
-'Session',
-'ASync',
-'Byte',
-'Caching',
-'Char',
-'Array',
-'List',
-'Xml',
-'Streaming',
-'Multipart',
-'Throttle',
-'Parallel',
-'Service',
-'Task',
-'Trigger',
-'Binding',
-'Remote',
-'ToString',
-'Enum',
-'Style',
-'IO',
-'DependsOn',
-'Embedded',
-'Database',
-'Client',
-'Service',
-'Expected',
-'Proxy',
-'Jax',
-'Name',
-'Request',
-'Pooled',
-'Json',
-'Parameterized',
-'NonTransient',
-'Instanceof',
-'ParamAware',
-'Socket',
-'Sequence',
-'Undefined',
-'Loader',
-'Invocation',
-'Timed',
-'Method',
-'MaxValue',
-'MinValue',
-'Url',
-'Resource',
-'Pattern',
-'Help',
-'Entity',
-'Invocation',
-'Extracting',
-'Servlet',
-'Script',
-'ResultSet',
-'Scope',
-'Application',
-'Mail',
-'Throwaway',
-'Connection',
-'Node',
-'Static',
-'Procedure',
-'Labeled',
-'Toolbox',
-'Command',
-'View',
-'Model',
-'Feed',
-'Manual']
+app = Flask(__name__)
+with open('data.yaml', 'r') as data_file:
+    data = yaml.load(data_file)
 
-LASTS = [
-'Logger',
-'Handler',
-'Exception',
-'Adapter',
-'Factory',
-'Bean',
-'Context',
-'Resolver',
-'Detector',
-'Advisor',
-'Interceptor',
-'Translator',
-'PostProcessor',
-'TaskExecutor',
-'Controller',
-'Loader',
-'Module',
-'Scope',
-'Override',
-'Descriptor',
-'Configurer',
-'Utils',
-'Generator',
-'Expression',
-'Wrapper',
-'Chain',
-'Dispatcher',
-'Validator',
-'Literal',
-'Tag',
-'Dao',
-'Daemon',
-'Template']
 
 @app.route("/")
 def main():
     class_name = generate_class_name()
     return render_template('index.html', class_name=class_name)
 
+
 def generate_class_name():
-    return choice(FIRSTS) + ''.join(sample(MIDDLES, 4)) + choice(LASTS)
+    return (choice(data['firsts']) + 
+            ''.join(sample(data['middles'], 4)) + 
+            choice(data['lasts']))
+
 
 if __name__ == "__main__":
-    app.run()
+    app.run(host='0.0.0.0')