コード例 #1
0
ファイル: Wrangler.py プロジェクト: jefftrevino/abjad
 def _get_available_path(
     self,
     message=None,
     storehouse_path=None,
     ):
     storehouse_path = storehouse_path or self._current_storehouse_path
     while True:
         default_prompt = 'enter {} name'.format(self._asset_identifier)
         message = message or default_prompt
         getter = self._io_manager._make_getter()
         getter.append_string(message)
         name = getter._run()
         if self._session.is_backtracking or not name:
             return
         name = stringtools.strip_diacritics(name)
         words = stringtools.delimit_words(name)
         words = [_.lower() for _ in words]
         name = '_'.join(words)
         if not stringtools.is_snake_case_package_name(name):
             continue
         path = os.path.join(storehouse_path, name)
         if os.path.exists(path):
             line = 'path already exists: {!r}.'
             line = line.format(path)
             self._io_manager._display(line)
         else:
             return path
コード例 #2
0
 def _get_available_path(
     self,
     message=None,
     storehouse_path=None,
 ):
     storehouse_path = storehouse_path or self._current_storehouse_path
     while True:
         default_prompt = 'enter {} name'.format(self._asset_identifier)
         message = message or default_prompt
         getter = self._io_manager._make_getter()
         getter.append_string(message)
         name = getter._run()
         if self._session.is_backtracking or not name:
             return
         name = stringtools.strip_diacritics(name)
         words = stringtools.delimit_words(name)
         words = [_.lower() for _ in words]
         name = '_'.join(words)
         if not stringtools.is_snake_case_package_name(name):
             continue
         path = os.path.join(storehouse_path, name)
         if os.path.exists(path):
             line = 'path already exists: {!r}.'
             line = line.format(path)
             self._io_manager._display(line)
         else:
             return path
コード例 #3
0
def to_dash_case(string):
    r'''Changes `string` to dash case.

    ..  container:: example

        Changes words to dash case:

        ::

            >>> stringtools.to_dash_case('scale degrees 4 and 5')
            'scale-degrees-4-and-5'

    ..  container:: example

        Changes snake case to dash case:

        ::

            >>> stringtools.to_dash_case('scale_degrees_4_and_5')
            'scale-degrees-4-and-5'

    ..  container:: example

        Changes dash case to dash case:

        ::

            >>> stringtools.to_dash_case('scale-degrees-4-and-5')
            'scale-degrees-4-and-5'

    ..  container:: example

        Changes upper camel case to dash case:

        ::

            >>> stringtools.to_dash_case('ScaleDegrees4And5')
            'scale-degrees-4-and-5'

    Returns string.
    '''
    from abjad.tools import stringtools

    words = stringtools.delimit_words(string)
    words = [_.lower() for _ in words]
    result = '-'.join(words)

    return result