map the path to a camelized logical_id. Example:
   /tmp/jets/demo/templates/demo-dev-2-posts_controller.yml to
   PostsController
771836
def app_logical_id
      regexp = Regexp.new(".*#{Jets.config.project_namespace}-app-")
      controller_name = @path.sub(regexp, '').sub('.yml', '')
      controller_name.underscore.camelize
    end
1310132
def translate_paths (properties, path):
    
    assert is_iterable_typed(properties, Property)
    result = []

    for p in properties:

        if p.feature.path:
            values = __re_two_ampersands.split(p.value)

            new_value = "&&".join(os.path.normpath(os.path.join(path, v)) for v in values)

            if new_value != p.value:
                result.append(Property(p.feature, new_value, p.condition))
            else:
                result.append(p)

        else:
            result.append (p)

    return result
1226447
def declare_api_routes(config):
    """"""
    # The pregenerator makes sure we can generate a path using
    # request.route_path even if we don't have all the variables.
    #
    # For example, instead of having to do this:
    #     request.route_path('resource', hash=hash, ignore='')
    # it's possible to do this:
    #     request.route_path('resource', hash=hash)
    def pregenerator(path):
        # find all the variables in the path
        variables = [(s.split(':')[0], '') for s in path.split('{')[1:]]

        def wrapper(request, elements, kwargs):
            modified_kwargs = dict(variables)
            modified_kwargs.update(kwargs)
            return elements, modified_kwargs
        return wrapper

    def add_route(name, path, *args, **kwargs):
        return config.add_route(name, path, *args,
                                pregenerator=pregenerator(path), **kwargs)

    add_route('content', '/contents/{ident_hash:([^:/@.]+(@[0-9.]*[0-9]+)?)}{separator:(:?)}{page_ident_hash:([^:/@.]+(@[0-9.]*[0-9]+)?)?}{ignore:(/[^/.]*?/?)?}{ext:([.](html|json))?}')  # noqa cnxarchive.views:get_content
    add_route('resource', '/resources/{hash}{ignore:(/.*)?}')  # noqa cnxarchive.views:get_resource
    add_route('export', '/exports/{ident_hash}.{type}{ignore:(/.*)?}')  # noqa cnxarchive.views:get_export
    add_route('extras', '/extras{key:(/(featured|messages|licenses|subjects|languages))?}')  # noqa cnxarchive.views:extras
    add_route('content-extras', '/extras/{ident_hash:([^:/@.]+(@[0-9.]*[0-9]+)?)}{separator:(:?)}{page_ident_hash:([^:/@.]+(@[0-9.]*[0-9]+)?)?}')  # noqa cnxarchive.views:get_extra
    add_route('search', '/search')  # cnxarchive.views:search
    add_route('in-book-search', '/search/{ident_hash:([^:/]+)}')  # noqa cnxarchive.views:in-book-search
    add_route('in-book-search-page', '/search/{ident_hash:([^:/]+)}:{page_ident_hash}')  # noqa cnxarchive.views:in_book_search_highlighted_results
    add_route('sitemap-index', '/sitemap_index.xml')  # noqa cnxarchive.views:sitemap
    add_route('sitemap', '/sitemap-{from_id}.xml')  # noqa cnxarchive.views:sitemap
    add_route('robots', '/robots.txt')  # noqa cnxarchive.views:robots
    add_route('legacy-redirect', '/content/{objid}{ignore:(/)?}')  # noqa cnxarchive.views:redirect_legacy_content
    add_route('legacy-redirect-latest', '/content/{objid}/latest{ignore:(/)?}{filename:(.+)?}')  # noqa cnxarchive.views:redirect_legacy_content
    add_route('legacy-redirect-w-version', '/content/{objid}/{objver}{ignore:(/)?}{filename:(.+)?}')  # noqa cnxarchive.views:redirect_legacy_content
    add_route('recent', '/feeds/recent.rss')  # cnxarchive.views:recent
    add_route('oai', '/feeds/oai')  # cnxarchive.views:oai
    add_route('xpath', '/xpath.html')  # cnxarchive.views.xpath
    add_route('xpath-json', '/xpath.json')
574795
def path_upper(
        cls, object_id, limit_depth=1000000, db_session=None, *args, **kwargs
    ):
        
        tablename = cls.model.__table__.name
        raw_q = """
            WITH RECURSIVE subtree AS (
                    SELECT res.*, 1 as depth FROM {tablename} res
                    WHERE res.resource_id = :resource_id
                  UNION ALL
                    SELECT res_u.*, depth+1 as depth
                    FROM {tablename} res_u, subtree st
                    WHERE res_u.resource_id = st.parent_id
            )
            SELECT * FROM subtree WHERE depth<=:depth;
        """.format(
            tablename=tablename
        )
        db_session = get_db_session(db_session)
        q = (
            db_session.query(cls.model)
            .from_statement(sa.text(raw_q))
            .params(resource_id=object_id, depth=limit_depth)
        )
        return q
1177033
def get_id_by_impath(path):
        '''
        
        '''
        logger.info('Get Entiry, Path: {0}'.format(path))

        entity_list = TabEntity.select().where(TabEntity.path == path)
        out_val = None
        if entity_list.count() == 1:
            out_val = entity_list.get()
        elif entity_list.count() > 1:
            for rec in entity_list:
                MEntity.delete(rec.uid)
            out_val = None
        else:
            pass
        return out_val
399620
def new_path(model_class, url_params: {})
      url_for url_params.to_h.reverse_merge(
        resources: to_resources_name(model_class),
        action: :new
      )
    end
97343
def _path_condition_name(self, api_id, path):
        
        # only valid characters for CloudFormation logical id are [A-Za-z0-9], but swagger paths can contain
        # slashes and curly braces for templated params, e.g., /foo/{customerId}. So we'll replace
        # non-alphanumeric characters.
        path_logical_id = path.replace('/', 'SLASH').replace('{', 'OB').replace('}', 'CB')
        return '{}{}PathCondition'.format(api_id, path_logical_id)
548810
public function basepath()
    {
        $defaultPath = 'webroot{DS}files{DS}{model}{DS}{field}{DS}';
        $path = Hash::get($this->settings, 'path', $defaultPath);
        if (strpos($path, '{primaryKey}') !== false) {
            if ($this->entity->isNew()) {
                throw new LogicException('{primaryKey} substitution not allowed for new entities');
            }
            if (is_array($this->table->getPrimaryKey())) {
                throw new LogicException('{primaryKey} substitution not valid for composite primary keys');
            }
        }

        $replacements = [
            '{primaryKey}' => $this->entity->get($this->table->getPrimaryKey()),
            '{model}' => $this->table->getAlias(),
            '{table}' => $this->table->getTable(),
            '{field}' => $this->field,
            '{year}' => date("Y"),
            '{month}' => date("m"),
            '{day}' => date("d"),
            '{time}' => time(),
            '{microtime}' => microtime(true),
            '{DS}' => DIRECTORY_SEPARATOR,
        ];

        if (preg_match_all("/{field-value:(\w+)}/", $path, $matches)) {
            foreach ($matches[1] as $field) {
                $value = $this->entity->get($field);
                if ($value === null) {
                    throw new LogicException(sprintf('Field value for substitution is missing: %s', $field));
                } elseif (!is_scalar($value)) {
                    throw new LogicException(sprintf('Field value for substitution must be a integer, float, string or boolean: %s', $field));
                } elseif (strlen($value) < 1) {
                    throw new LogicException(sprintf('Field value for substitution must be non-zero in length: %s', $field));
                }

                $replacements[sprintf('{field-value:%s}', $field)] = $value;
            }
        }

        return str_replace(
            array_keys($replacements),
            array_values($replacements),
            $path
        );
    }
755637
def relation_path_for(from_name, to_name, identifier_type, identifier_key=None):
    
    return "/{}/<{}:{}>/{}".format(
        name_for(from_name),
        identifier_type,
        identifier_key or "{}_id".format(name_for(from_name)),
        name_for(to_name),
    )
877013
private function typePathInfo()
    {
        $request = Request::createFromGlobals();
        $pathInfo = $request->getPathInfo();
        // Set Controller and Action
        $urlArray = explode('/', $pathInfo);
        $controllerName = 'index';
        if (!empty($urlArray[1])) {
            $controllerName = $urlArray[1];
        }
        $controllerName = ucfirst(strtolower($controllerName));
        $actionName = 'index';
        if (!empty($urlArray[2])) {
            $actionName = $urlArray[2];
        }
        // Parameter
        $urlList = array(0, 1, 2);
        foreach ($urlArray as $key => $value) {
            if (!in_array($key, $urlList)) {
                if ($key % 2 == 0) {
                    $_GET[$urlArray[$key - 1]] = empty($value) ? '' : $value;
                }
            }
        }
        $route = $controllerName . '.' . $actionName;
        return $this->render($route);
    }
732973
def get_template_path(self, content=None):
        
        if isinstance(content, Paginator):
            return op.join('api', 'paginator.%s' % self.format)

        if isinstance(content, UpdatedList):
            return op.join('api', 'updated.%s' % self.format)

        app = ''
        name = self.resource._meta.name

        if not content:
            content = self.resource._meta.model

        if isinstance(content, (Model, ModelBase)):
            app = content._meta.app_label
            name = content._meta.module_name

        basedir = 'api'
        if getattr(self.resource, 'api', None):
            basedir = self.resource.api.prefix

        return op.join(
            basedir,
            str(self.resource.api or ''), app, "%s.%s" % (name, self.format)
        )
954038
def gen_post_map(file_name, ext_url=''):
    '''
    
    '''
    with open(file_name, 'a') as fout:
        for kind_key in router_post:
            recent_posts = MPost.query_all(kind=kind_key, limit=1000000)
            for recent_post in recent_posts:
                url = os.path.join(SITE_CFG['site_url'],
                                   router_post[recent_post.kind],
                                   ext_url,
                                   recent_post.uid)
                fout.write('{url}\n'.format(url=url))
496963
def controller
      unless params[:controller]
        raise ControllerExceptions::NotFound,
          "Route matched, but route did not specify a controller.\n" +
          "Did you forgot to add :controller => \"people\" or :controller " +
          "segment to route definition?\nHere is what's specified:\n" +
          route.inspect
      end
      path = [params[:namespace], params[:controller]].compact.join(Merb::Const::SLASH)
      controller = path.snake_case.to_const_string

      begin
        Object.full_const_get(controller)
      rescue NameError => e
        msg = "Controller class not found for controller `#{path}'"
        Merb.logger.warn!(msg)
        raise ControllerExceptions::NotFound, msg
      end
    end
851696
def build_child_template(path)
      md = path.match(%r{app/(.*?)/}) # extract: controller, job or function
      process_class = md[1].classify
      builder_class = "Jets::Cfn::Builders::#{process_class}Builder".constantize

      # Examples:
      #   Jets::Cfn::Builders::ControllerBuilder.new(PostsController)
      #   Jets::Cfn::Builders::JobBuilder.new(EasyJob)
      #   Jets::Cfn::Builders::RuleBuilder.new(CheckRule)
      #   Jets::Cfn::Builders::FunctionBuilder.new(Hello)
      #   Jets::Cfn::Builders::FunctionBuilder.new(HelloFunction)
      app_class = Jets::Klass.from_path(path)
      builder = builder_class.new(app_class)
      unless Jets.poly_only? && app_class == Jets::PreheatJob
        builder.build
      end
    end
315511
@Override
    public void visit(NormalAnnotationExpr anno, ControllerModel controller) {

        //org.wisdom.api.annotations.Path (There is only one pair ->value="")
        if(anno.getName().getName().equals(ANNOTATION_PATH)){
            java.lang.String path = asString(anno.getPairs().get(0).getValue());
            controller.setBasePath(path);
        }
    }
1022912
function (items, id_path, done) {

      done = typeof id_path == 'function' ? id_path : done

      var next = function(item, cb) {
        debug('creating %s', type)

        File.create(item[file_type], function(err, items) {
          if(err)
            return cb(err)

          item[file_type] = Array.prototype.slice.call(arguments, 1)
          debug('%s %s created', item[file_type].length, file_type)

          models[type].create(item, function(err, item) {
            if(err)
              return cb(err)

            debug('item created')

            if(id_path) {
              debug('Saving item to path')
              require('./paths')
              .files.add(id_path, item, function(err, path) {
                cb(err, item)
              })
            } else
              return cb(null, item)

          })
        })

      }

      if(items instanceof Array) {
        async.map(items, next,	done)
      } else {
        next(items, done)
      }
    }
739101
def template_path(key, partial_root)
      path = key.split(".")
      path.delete_at(0) if path[0] == "activity"
      path.unshift partial_root
      path.join("/")
    end