This commit is contained in:
Errol Sancaktar 2024-08-19 14:45:05 -06:00
parent a04d9594f3
commit 15361dc75c
15012 changed files with 6 additions and 2960001 deletions

View File

@ -14,7 +14,7 @@ declare -A alias_list=(
[python]='python3'
# PYTHON
[ve]='source venv/bin/activate'
[act]='source venv/bin/activate'
[p]='ipython'
# GIT
@ -29,6 +29,7 @@ declare -A alias_list=(
[grv]='git remote --verbose'
[gs]='git show --pretty=short'
[gst]='git status --short'
[gss]='git status --long --show-stash'
[gd]='git diff'
[gdca]='git diff --cached'
[gdcw]='git diff --cached --word-diff'
@ -41,6 +42,9 @@ declare -A alias_list=(
# KUBERNETES
[k]='kubectl'
[kgc]='kubectl config get-contexts'
[kuc]='kubectl config use-context'
# TERRAFORM
[t]='tofu'

View File

@ -1,20 +0,0 @@
// This configuration file allows you to pass permanent command line arguments to VS Code.
// Only a subset of arguments is currently supported to reduce the likelihood of breaking
// the installation.
//
// PLEASE DO NOT CHANGE WITHOUT UNDERSTANDING THE IMPACT
//
// NOTE: Changing this file requires a restart of VS Code.
{
// Use software rendering instead of hardware accelerated rendering.
// This can help in cases where you see rendering issues in VS Code.
// "disable-hardware-acceleration": true,
// Allows to disable crash reporting.
// Should restart the app if the value is changed.
"enable-crash-reporter": true,
// Unique id used for correlating crash reports sent from this instance.
// Do not edit this value.
"crash-reporter-id": "85c4a9e2-2510-427a-a803-2ea801f38920"
}

View File

@ -1 +0,0 @@
{"ms-python.python-2024.10.0-darwin-arm64":true}

View File

@ -1,12 +0,0 @@
# These are supported funding model platforms
github: [batisteo]
patreon: # Replace with a single Patreon username
open_collective: # Replace with a single Open Collective username
ko_fi: # Replace with a single Ko-fi username
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
liberapay: batisteo
issuehunt: # Replace with a single IssueHunt username
otechie: # Replace with a single Otechie username
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']

View File

@ -1,46 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<PackageManifest Version="2.0.0" xmlns="http://schemas.microsoft.com/developer/vsx-schema/2011" xmlns:d="http://schemas.microsoft.com/developer/vsx-schema-design/2011">
<Metadata>
<Identity Language="en-US" Id="vscode-django" Version="1.15.0" Publisher="batisteo" />
<DisplayName>Django</DisplayName>
<Description xml:space="preserve">Beautiful syntax and scoped snippets for perfectionists with deadlines</Description>
<Tags>python,django,web,snippet,django-html,Django HTML,django-txt,Django txt,__web_extension</Tags>
<Categories>Programming Languages,Snippets</Categories>
<GalleryFlags>Public</GalleryFlags>
<Properties>
<Property Id="Microsoft.VisualStudio.Code.Engine" Value="^1.49.0" />
<Property Id="Microsoft.VisualStudio.Code.ExtensionDependencies" Value="" />
<Property Id="Microsoft.VisualStudio.Code.ExtensionPack" Value="" />
<Property Id="Microsoft.VisualStudio.Code.ExtensionKind" Value="workspace,web" />
<Property Id="Microsoft.VisualStudio.Code.LocalizedLanguages" Value="" />
<Property Id="Microsoft.VisualStudio.Services.Links.Source" Value="https://github.com/vscode-django/vscode-django.git" />
<Property Id="Microsoft.VisualStudio.Services.Links.Getstarted" Value="https://github.com/vscode-django/vscode-django.git" />
<Property Id="Microsoft.VisualStudio.Services.Links.GitHub" Value="https://github.com/vscode-django/vscode-django.git" />
<Property Id="Microsoft.VisualStudio.Services.Links.Support" Value="https://github.com/vscode-django/vscode-django/issues" />
<Property Id="Microsoft.VisualStudio.Services.Links.Learn" Value="https://github.com/vscode-django/vscode-django" />
<Property Id="Microsoft.VisualStudio.Services.Branding.Color" Value="#0c4b33" />
<Property Id="Microsoft.VisualStudio.Services.Branding.Theme" Value="dark" />
<Property Id="Microsoft.VisualStudio.Services.GitHubFlavoredMarkdown" Value="true" />
<Property Id="Microsoft.VisualStudio.Services.Content.Pricing" Value="Free"/>
</Properties>
<License>extension/LICENSE.txt</License>
<Icon>extension/images/vscode-django-icon.png</Icon>
</Metadata>
<Installation>
<InstallationTarget Id="Microsoft.VisualStudio.Code"/>
</Installation>
<Dependencies/>
<Assets>
<Asset Type="Microsoft.VisualStudio.Code.Manifest" Path="extension/package.json" Addressable="true" />
<Asset Type="Microsoft.VisualStudio.Services.Content.Details" Path="extension/README.md" Addressable="true" />
<Asset Type="Microsoft.VisualStudio.Services.Content.Changelog" Path="extension/CHANGELOG.md" Addressable="true" />
<Asset Type="Microsoft.VisualStudio.Services.Content.License" Path="extension/LICENSE.txt" Addressable="true" />
<Asset Type="Microsoft.VisualStudio.Services.Icons.Default" Path="extension/images/vscode-django-icon.png" Addressable="true" />
</Assets>
</PackageManifest>

View File

@ -1,7 +0,0 @@
# Change Log
All notable changes to the "django" extension will be documented in this file.
Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how to structure this file.
## [Unreleased]
- Initial release

View File

@ -1,21 +0,0 @@
The MIT License (MIT)
Copyright (c) 2021 vscode-django contributors
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.

View File

@ -1,4 +0,0 @@
all: publish
publish:
vsce publish

View File

@ -1,99 +0,0 @@
# Django extension for Visual Studio Code
> Beautiful syntax and scoped snippets for perfectionists with deadlines
![Syntax with Gruvbox](https://github.com/vscode-django/vscode-django/raw/HEAD/images/vscode-django-syntax-gruvbox.png)
## Features
### Go to definition in templates
Ctrl+click (cmd+click on MacOS) or press F12 on the template path in a `include` or `extends` tag
to jump to this template
### Snippets
- Support for selected text (when inserting snippet from the menu)
- Support for copied text
- No unnecessary new lines
### Improved syntax
- Adds the filetype `django-html`
- Adds the filetype `django-txt` for email templates.
- Better syntax with more operators and default keywords:
- Known default tags and filters
- Known templatetags namespace from contrib in the {% load %} tag
- Known keywords in tags, like: `as`, `asvar`, `with`, `trimmed`
- Syntax highlighting everywhere in your HTML document:
- In the HTML tag itself"
- In the id, class or any attribute
- In inline CSS or Javascript code
## Tricks
### Gettext and internationalization
Dealing with `django.po` files?
Consider installing the [Gettext extension](https://marketplace.visualstudio.com/items?itemName=mrorz.language-gettext) by MrOrz.
### Emmet
Add the following item to the **Emmet: Include Languages** settings:
| Item | Value |
| ------------- | ------ |
| `django-html` | `html` |
## Sponsors
- [tpberntsen](https://github.com/tpberntsen)
- [moving-content](https://github.com/moving-content)
[![Paypal](https://img.shields.io/static/v1?label=Paypal&message=€66&logo=Paypal&color=009cde&link=https://www.paypal.com/paypalme/batisteo/5)](https://www.paypal.com/paypalme/batisteo/5)
[![Github Sponsor](https://img.shields.io/static/v1?label=Sponsor&message=6%C2%A0%E2%9D%A4&logo=GitHub&color=ea4aaa&link=https://github.com/sponsor/batisteo)](https://github.com/sponsor/batisteo)
## Contributing
### Issues
Something odd? New feature request?
Please [create an issue on Github](https://github.com/vscode-django/vscode-django/issues/new).
### Setup
```bash
git clone https://github.com/vscode-django/vscode-django
cd vscode-django
npm install
code .
```
Its better to have [TSlint](https://marketplace.visualstudio.com/items?itemName=eg2.tslint) installed.
### Launching the extension debugger
Make sure you have this snippet in `.vscode/launch.json`:
```javascript
{
"version": "0.2.0",
"configurations": [
{
"name": "Extension",
"type": "extensionHost",
"request": "launch",
"runtimeExecutable": "${execPath}",
"args": [
"--extensionDevelopmentPath=${workspaceFolder}"
]
}
]
}
```
Press <kbd>F5</kbd> or click on Debug then Start (▶️) to launch the extension host window.
Hack around
Press <kbd>Ctrl</kbd> + <kbd>Shift</kbd> + <kbd>F5</kbd> or 🔄 to reload.

View File

@ -1,47 +0,0 @@
[[snippets]]
prefix = "class_modeladmin"
body = """
@admin.register($1)
class $1Admin(admin.ModelAdmin):
$0
"""
detail = "class ModelAdmin(admin.ModelAdmin)"
description = """```python
@admin.register(Model)
class ModelAdmin(admin.ModelAdmin):
```
"""
[[snippets]]
prefix = "class_stackedinline"
body = """
class ${1}Inline(admin.StackedInline):
model = $1
${2|extra,min_num,max_num,can_delete,show_change_link,verbose_name,verbose_name_plural,fk_name,template,formset|}
"""
description = "Stacked Inline"
[[snippets]]
prefix = "class_tabularinline"
body = """
class $1Inline(admin.TabularInline):
model = $1
${2|extra,min_num,max_num,can_delete,show_change_link,verbose_name,verbose_name_plural,fk_name,template,formset|}
"""
description = "Tabular Inline"
[[snippets]]
prefix = "class_simplelistfilter"
body = """
class $1Filter(admin.SimpleListFilter):
title = _("${2:$1}")
parameter_name = "$3"
def lookups(self, request, model_admin):
return ($0)
def queryset(self, request, queryset):
return queryset.filter($3=self.value())
"""
description = "Admin SimpleList Filter"

View File

@ -1,18 +0,0 @@
[[snippets]]
prefix = "import_admin"
body = "from django.contrib import admin"
detail = "from * import admin"
description = """```python
from django.contrib import admin
```
"""
[[snippets]]
prefix = "import_adminsite"
body = "from django.contrib.admin import AdminSite"
detail = "from * import AdminSite"
description = """```python
from django.contrib import AdminSite
```
"""

View File

@ -1,47 +0,0 @@
[[snippets]]
prefix = "admin_param"
body = "${1|list_display,list_display_links,list_filter,list_select_related,list_per_page,list_max_show_all,list_editable,search_fields,date_hierarchy,save_as,save_as_continue,save_on_top,paginator,preserve_filters,inlines,add_form_template,change_form_template,change_list_template,delete_confirmation_template,delete_selected_confirmation_template,object_history_template,popup_response_template,actions,action_form,actions_on_top,actions_on_bottom,actions_selection_counter,checks_class|} = "
detail = "ModelAdmin parameters"
description = """```python
list_display = ("",)
search_fields = ("",)
date_hierarchy = ("",)
```
"""
[[snippets]]
prefix = "inline_param"
body = "${1|extra,min_num,max_num,can_delete,show_change_link,verbose_name,verbose_name_plural,fk_name,template,formset|} = "
detail = "Inline parameters"
description = """```python
extra = 1
min_num = 3
max_num = 20
```
"""
[[snippets]]
prefix = "fieldsets"
body = """
fieldsets = (
(None, {
"fields": (
$1
),
}),
)
"""
detail = "fieldsets = ((None, {}))"
description = """```python
fieldsets = (
(None, {
"fields": (
$1
),
}),
)
```
"""

View File

@ -1,21 +0,0 @@
[[snippets]]
prefix = "Form"
body = """
class $1Form(forms.Form):
$0
"""
detail = "class Form(forms.Form)"
description = ""
[[snippets]]
prefix = "ModelForm"
body = """
class $1Form(forms.ModelForm):
$0
class Meta:
model = $1
fields = ("$2",$3)
"""
detail = "class $1Form(forms.ModelForm)"
description = ""

View File

@ -1,50 +0,0 @@
[[snippets]]
prefix = "simplearray_field"
body = "SimpleArrayField()"
description = "postgres.forms.SimpleArrayField()"
[[snippets]]
prefix = "splitarray_field"
body = "SplitArrayField()"
description = "postgres.forms.SplitArrayField()"
[[snippets]]
prefix = "hstore_field"
body = "HStoreField()"
description = "postgres.forms.HStoreField()"
[[snippets]]
prefix = "json_field"
body = "JSONField()"
description = "postgres.forms.JSONField()"
[[snippets]]
prefix = "intrange_field"
body = "IntegerRangeField()"
description = "postgres.forms.IntegerRangeField()"
[[snippets]]
prefix = "floatrange_field"
body = "FloatRangeField()"
description = "postgres.forms.FloatRangeField()"
[[snippets]]
prefix = "datetimerange_field"
body = "DateTimeRangeField()"
description = "postgres.forms.DateTimeRangeField()"
[[snippets]]
prefix = "daterange_field"
body = "DateRangeField()"
description = "postgres.forms.DateRangeField()"
[[snippets]]
prefix = "range_widget"
body = "RangeWidget(${1:base_widget=})"
detail = "postgres.forms.RangeWidget()"
description = """```python
class RangeWidget(base_widget, attrs=None)
```
"""

View File

@ -1,150 +0,0 @@
[[snippets]]
prefix = "bool_field"
body = "forms.BooleanField($1, required=${2:False})"
detail = "forms.BooleanField()"
[[snippets]]
prefix = "char_field"
body = "forms.CharField($1,${2: max_length=$4,} required=${5:False})"
detail = "forms.CharField()"
[[snippets]]
prefix = "choice_field"
body = "forms.ChoiceField($1, choices=[${2:CHOICES}], required=${4:False})"
detail = "forms.ChoiceField()"
[[snippets]]
prefix = "combo_field"
body = "forms.ComboField($1)"
detail = "forms.ComboField()"
[[snippets]]
prefix = "date_field"
body = "forms.DateField($1, required=${2:False})"
detail = "forms.DateField()"
[[snippets]]
prefix = "datetime_field"
body = "forms.DateTimeField($1, required=${2:False})"
detail = "forms.DateTimeField()"
[[snippets]]
prefix = "decimal_field"
body = "forms.DecimalField($1, required=${2:False})"
detail = "forms.DecimalField()"
[[snippets]]
prefix = "duration_field"
body = "forms.DurationField($1, required=${2:False})"
detail = "forms.DurationField()"
[[snippets]]
prefix = "email_field"
body = "forms.EmailField($1, required=${2:False})"
detail = "forms.EmailField()"
[[snippets]]
prefix = "file_field"
body = "forms.FileField($1,${2: max_length=$4,} required=${5:False})"
detail = "forms.FileField()"
[[snippets]]
prefix = "filepath_field"
body = "forms.FilePathField($1, path=${2:/absolute_path/}, required=${4:False})"
detail = "forms.FilePathField()"
[[snippets]]
prefix = "float_field"
body = "forms.FloatField($1, required=${2:False})"
detail = "forms.FloatField()"
[[snippets]]
prefix = "ip_field"
body = "forms.GenericIPAddressField($1)"
detail = "forms.GenericIPAddressField()"
[[snippets]]
prefix = "img_field"
body = "forms.ImageField($1, required=${2:False})"
detail = "forms.ImageField()"
[[snippets]]
prefix = "int_field"
body = "forms.IntegerField($1, required=${2:False})"
detail = "forms.IntegerField()"
[[snippets]]
prefix = "json_field"
body = "forms.JSONField($1)"
detail = "forms.JSONField()"
[[snippets]]
prefix = "mochoice_field"
body = "forms.ModelChoiceField($1)"
detail = "forms.ModelChoiceField()"
[[snippets]]
prefix = "momuchoice_field"
body = "forms.ModelMultipleChoiceField($1)"
detail = "forms.ModelMultipleChoiceField()"
[[snippets]]
prefix = "muval_field"
body = "forms.MultiValueField($1)"
detail = "forms.MultiValueField()"
[[snippets]]
prefix = "muchoice_field"
body = "forms.MultipleChoiceField($1, choices=[${2:CHOICES}], required=${4:False})"
detail = "forms.MultipleChoiceField()"
[[snippets]]
prefix = "typedmuchoice_field"
body = "forms.TypedMultipleChoiceField($1, choices=[${2:CHOICES}], coerce=${4:TYPE}, required=${5:False})"
detail = "forms.TypedMultipleChoiceField()"
[[snippets]]
prefix = "nullbool_field"
body = "forms.NullBooleanField($1, required=${2:False})"
detail = "forms.NullBooleanField()"
[[snippets]]
prefix = "regex_field"
body = "forms.RegexField($1, regex=${2:REGEX}, required=${4:False})"
detail = "forms.RegexField()"
[[snippets]]
prefix = "slug_field"
body = "forms.SlugField($1, allow_unicode=${2:False}, required=${4:False})"
detail = "forms.SlugField()"
[[snippets]]
prefix = "sdatetime_field"
body = "forms.SplitDateTimeField($1)"
detail = "forms.SplitDateTimeField()"
[[snippets]]
prefix = "time_field"
body = "forms.TimeField($1, required=${2:False})"
detail = "forms.TimeField()"
[[snippets]]
prefix = "tchoice_field"
body = "forms.TypedChoiceField($1, required=${2:False})"
detail = "forms.TypedChoiceField()"
[[snippets]]
prefix = "tmuchoice_field"
body = "forms.TypedMultipleChoiceField($1)"
detail = "forms.TypedMultipleChoiceField()"
[[snippets]]
prefix = "url_field"
body = "forms.URLField($1, required=${2:False})"
detail = "forms.URLField()"
[[snippets]]
prefix = "uuid_field"
body = "forms.UUIDField($1, required=${2:False})"
detail = "forms.UUIDField()"

View File

@ -1,17 +0,0 @@
[[snippets]]
prefix = "from_forms_import"
body = "from .forms import $1"
detail = "from .forms import ModelForm"
description = "Relative import of app form"
[[snippets]]
prefix = "import_forms"
body = "from django import forms"
detail = "from django import forms"
description = "Imports the Django models module"
[[snippets]]
prefix = "import_postgres_fields"
body = "from django.contrib.postgres.forms import ${1|SimpleArrayField,SplitArrayField,HStoreField,JSONField,IntegerRangeField,FloatRangeField,DateTimeRangeField,DateRangeField|}"
description = "PostgreSQL specific forms fields"

View File

@ -1,22 +0,0 @@
[[snippets]]
prefix = "clean_data"
body = """
clean_${1:field}(self):
${2:data} = self.cleaned_data["${1:field}"]
$0
return ${2:data}
"""
detail = ""
description = ""
[[snippets]]
prefix = "clean_data_get"
body = """
clean_${1:field}(self):
${2:data} = self.cleaned_data.get("${1:field}")
$0
return ${2:data}
"""
detail = ""
description = ""

View File

@ -1,41 +0,0 @@
[[snippets]]
prefix = "Model"
detail = "class Model(models.Model)"
body = """
class $1(models.Model):
$0
class Meta:
verbose_name = _("${1/(.+)/${1:/downcase}/}")
verbose_name_plural = _("${1/(.+)/${1:/downcase}/}${2:s}")
def __str__(self):
return self.${3:name}
def get_absolute_url(self):
return reverse("${1/(.+)/${1:/downcase}/}${4:_detail}", kwargs={"${5|pk,slug|}": self.$5})
"""
[[snippets]]
prefix = "modelmixin"
detail = "class Mixin(models.Model)"
body = """
class $1Mixin(models.Model):
$0
class Meta:
abstract = True
"""
description = ""
[[snippets]]
prefix = "queryset"
detail = "class QuerySet(models.QuerySet)"
body = """
class $1QuerySet(models.QuerySet):
pass
"""
description = ""

View File

@ -1,64 +0,0 @@
# https://docs.djangoproject.com/en/stable/ref/contrib/postgres/fields/
[[snippets]]
prefix = 'postgres_array_field'
body = 'ArrayField(${1:base_field=})'
detail = 'ArrayField()'
[[snippets]]
prefix = 'postgres_hstore_field'
body = 'HStoreField($1)'
detail = 'HStoreField()'
[[snippets]]
prefix = 'postgres_ci_char_field'
body = 'CICharField($1)'
detail = 'CICharField()'
description = 'Case-insensitive CharField()'
[[snippets]]
prefix = 'postgres_ci_email_field'
body = 'CIEmailField($1)'
detail = 'CIEmailField()'
description = 'Case-insensitive EmailField()'
[[snippets]]
prefix = 'postgres_ci_text_field'
body = 'CITextField($1)'
detail = 'CITextField()'
description = 'Case-insensitive TextField()'
[[snippets]]
prefix = 'postgres_json_field'
body = 'JSONField(${1:encoder="$2"})'
detail = 'JSONField()'
[[snippets]]
prefix = 'postgres_integer_range_field'
body = 'IntegerRangeField($1)'
detail = "IntegerRangeField()"
description = "Stores a range of integers."
[[snippets]]
prefix = 'postgres_big_integer_range_field'
body = 'BigIntegerRangeField($1)'
detail = "BigIntegerRangeField()"
description = "Stores a range of large integers."
[[snippets]]
prefix = 'postgres_float_range_field'
body = 'FloatRangeField($1)'
detail = "FloatRangeField()"
description = "Stores a range of floating point values."
[[snippets]]
prefix = 'postgres_date_time_range_field'
body = 'DateTimeRangeField($1)'
detail = "DateTimeRangeField()"
description = "Stores a range of timestamps."
[[snippets]]
prefix = 'postgres_date_range_field'
body = 'DateRangeField($1)'
detail = "DateRangeField()"
description = "Stores a range of dates."

View File

@ -1,193 +0,0 @@
# https://docs.djangoproject.com/en/stable/ref/models/fields/
[[snippets]]
prefix = 'auto_field'
body = 'models.AutoField(_("$1"))'
detail = 'models.AutoField()'
description = 'An IntegerField that automatically increments according to available IDs.'
[[snippets]]
prefix = 'big_auto_field'
body = 'models.BigAutoField(_("$1"))'
detail = 'models.BigAutoField()'
description = 'A 64-bit integer, much like an AutoField.'
[[snippets]]
prefix = 'big_integer_field'
body = 'models.BigIntegerField(_("$1"))'
detail = 'models.BigIntegerField()'
description = 'A 64-bit integer, much like an IntegerField.'
[[snippets]]
prefix = 'binary_field'
body = 'models.BinaryField(_("$1"))'
detail = 'models.BinaryField()'
description = 'A field to store raw binary data.'
[[snippets]]
prefix = 'boolean_field'
body = 'models.BooleanField(_("$1"))'
detail = 'models.BooleanField()'
description = 'A true/false field.'
[[snippets]]
prefix = 'char_field'
body = 'models.CharField(_("$1"), max_length=${3:50})'
detail = 'models.CharField()'
description = 'A string field, for small- to large-sized strings.'
[[snippets]]
prefix = 'date_field'
body = 'models.DateField(_("$1"), auto_now=${3:False}, auto_now_add=${4:False})'
detail = 'models.DateField()'
description = 'A date, represented in Python by a datetime.date instance.'
[[snippets]]
prefix = 'date_time_field'
body = 'models.DateTimeField(_("$1"), auto_now=${3:False}, auto_now_add=${4:False})'
detail = 'models.DateTimeField()'
description = 'A date, represented in Python by a datetime.datetime instance.'
[[snippets]]
prefix = 'decimal_field'
body = 'models.DecimalField(_("$1"), max_digits=${3:5}, decimal_places=${4:2})'
detail = 'models.DecimalField()'
description = 'A fixed-precision decimal number, represented in Python by a Decimal instance.'
[[snippets]]
prefix = 'duration_field'
body = 'models.DurationField(_("$1"))'
detail = 'models.DurationField()'
description = 'A field for storing periods of time - modeled in Python by timedelta.'
[[snippets]]
prefix = 'email_field'
body = 'models.EmailField(_("$1"), max_length=${3:254})'
detail = 'models.EmailField()'
description = 'A CharField that checks that the value is a valid email address.'
[[snippets]]
prefix = 'file_field'
body = 'models.FileField(_("$1"), upload_to=${3:None}, max_length=${4:100})'
detail = 'models.FileField()'
description = 'A file-upload field.'
[[snippets]]
prefix = 'file_path_field'
body = 'models.FilePathField(_("$1"), path=${3:None}, match=${4:None}, recursive=${5:recursive}, max_length=${6:100})'
detail = 'models.FilePathField()'
description = 'A CharField whose choices are limited to the filenames in a certain directory on the filesystem.'
[[snippets]]
prefix = 'float_field'
body = 'models.FloatField(_("$1"))'
detail = 'models.FloatField()'
description = 'A floating-point number represented in Python by a float instance.'
[[snippets]]
prefix = 'foreign_key'
body = 'models.ForeignKey("${1:app}.${2:Model}", verbose_name=_(""), on_delete=models.${3|CASCADE,PROTECT,SET_NULL,SET_DEFAULT,SET(),DO_NOTHING|})'
detail = 'models.ForeignKey()'
description = 'ForeignKey (fk).\n\nA many-to-one relationship.\n\non_delete will become a required argument in Django 2.0. In older versions it defaults to CASCADE.\n\n'
[[snippets]]
prefix = 'image_field'
body = 'models.ImageField(_("$1"), upload_to=${3:None}, height_field=${4:None}, width_field=${5:None}, max_length=${5:100})'
detail = 'models.ImageField()'
description = 'Inherits all attributes and methods from FileField, but also validates that the uploaded object is a valid image.'
[[snippets]]
prefix = 'integer_field'
body = 'models.IntegerField(_("$1"))'
detail = 'models.IntegerField()'
description = 'An integer. Values from -2147483648 to 2147483647 are safe in all databases supported by Django.'
[[snippets]]
prefix = 'generic_ip_address_field'
body = 'models.GenericIPAddressField(_("$1"), protocol=${3:"both"}, unpack_ipv4=${4:False})'
detail = 'models.GenericIPAddressField()'
description = 'An IPv4 or IPv6 address, in string format.'
[[snippets]]
prefix = 'json_field'
body = 'models.JSONField(_("$1")${2:, encoder=$3}${4:, decoder=$5})'
detail = 'models.JSONField()'
description = 'A field for storing JSON encoded data.'
[[snippets]]
prefix = 'many_to_many_field'
body = 'models.ManyToManyField("${1:app}.${2:Model}", verbose_name=_(""))'
detail = 'models.ManyToManyField()'
description = 'A many-to-many relationship.'
[[snippets]]
prefix = 'null_boolean_field'
body = 'models.NullBooleanField(_("$1"))'
detail = 'models.NullBooleanField()'
description = 'Like a BooleanField, but allows NULL as one of the options.'
[[snippets]]
prefix = 'one_to_one_field'
body = 'models.OneToOneField("${1:app}.${2:Model}", verbose_name=_(""), on_delete=models.${3|CASCADE,PROTECT,SET_NULL,SET_DEFAULT,SET(),DO_NOTHING|})'
detail = 'models.OneToOneField()'
description = 'A one-to-one relationship.'
[[snippets]]
prefix = 'phone_number_field'
body = 'models.PhoneNumberField(_("$1"))'
detail = 'models.PhoneNumberField()'
description = '*external package: django-phonenumber-field*'
[[snippets]]
prefix = 'positive_integer_field'
body = 'models.PositiveIntegerField(_("$1"))'
detail = 'models.PositiveIntegerField()'
description = 'Like an IntegerField, but must be either positive or zero (0).'
[[snippets]]
prefix = 'positive_small_integer_field'
body = 'models.PositiveSmallIntegerField(_("$1"))'
detail = 'models.PositiveSmallIntegerField()'
description = 'Like a PositiveIntegerField, but only allows values under a certain (database-dependent) point.'
[[snippets]]
prefix = 'slug_field'
body = 'models.SlugField(_("$1"))'
detail = 'models.SlugField()'
description = 'A slug is a short label for something, containing only letters, numbers, underscores or hyphens. Theyre generally used in URLs.'
[[snippets]]
prefix = 'small_integer_field'
body = 'models.SmallIntegerField(_("$1"))'
detail = 'models.SmallIntegerField()'
description = 'Like an IntegerField, but only allows values under a certain (database-dependent) point.'
[[snippets]]
prefix = 'text_field'
body = 'models.TextField(_("$1"))'
detail = 'models.TextField()'
description = 'A large text field.'
[[snippets]]
prefix = 'time_field'
body = 'models.TimeField(_("$1"), auto_now=${4:False}, auto_now_add=${5:False})'
detail = 'models.TimeField()'
description = 'A time, represented in Python by a datetime.time instance.'
[[snippets]]
prefix = 'url_field'
body = 'models.URLField(_("$1"), max_length=${3:200})'
detail = 'models.URLField()'
description = 'A CharField for a URL.'
[[snippets]]
prefix = 'us_state_field'
body = 'models.USStateField(_("$1"))'
detail = 'models.USStateField()'
description = '*external package: django-localflavor*'
[[snippets]]
prefix = 'uuid_field'
body = 'models.UUIDField(_("$1"))'
detail = 'models.UUIDField()'
description = 'A field for storing universally unique identifiers. Uses Pythons UUID class.'

View File

@ -1,36 +0,0 @@
[[snippets]]
prefix = "import_model"
body = "from .models import $1"
detail = "from .models import Model"
description = "Relative import of app model"
[[snippets]]
prefix = "import_manager"
body = "from .managers import $1Manager"
detail = "from .managers import Manager"
description = "Relative import of manager"
[[snippets]]
prefix = "import_queryset"
body = "from .managers import $1QuerySet"
detail = "from .managers import QuerySet"
description = "Relative import of queryset"
[[snippets]]
prefix = "import_db_models"
body = "from django.db import models"
detail = "from django.db import models"
description = "Imports the Django models module"
[[snippets]]
prefix = "import_postgres_models"
body = "from django.contrib.postgres.fields import ${1|ArrayField,JSONField,HStoreField,CICharField,CIEmailField,CITextField,IntegerRangeField,BigIntegerRangeField,FloatRangeField,DateTimeRangeField,DateRangeField|}"
detail = "from django.contrib.postgres.fields import"
description = "PostgreSQL specific model fields"
[[snippets]]
prefix = "import_signals"
body = "from django.db.models.signals import ${1|pre_init,post_init,pre_save,post_save,pre_delete,post_delete,m2m_changed,class_prepared,Management signals,pre_migrate,post_migrate|}"
detail = "from django.db.models.signals import"
description = "Signals for Django Model"

View File

@ -1,21 +0,0 @@
[[snippets]]
prefix = "manager"
detail = "class Manager(models.Manager)"
body = """
class $1Manager(models.Manager):
def get_queryset(self):
return super().get_queryset().${2|filter,exclude,order_by,distinct,reverse|}($3)
"""
description = "Add extra Manager methods"
[[snippets]]
prefix = "queryset_from_manager"
detail = "class Manager(models.Manager)"
body = """
class $1Manager(models.Manager):
def get_queryset(self):
return $1QuerySet(self.model, using=self._db)
}
"""
description = "Modify the initial QuerySet the Manager returns."

View File

@ -1,21 +0,0 @@
[[snippets]]
prefix = "__str__"
body = """
__str__(self):
return self.${3:name}
"""
[[snippets]]
prefix = "get_absolute_url"
body = """
get_absolute_url(self):
return reverse("${1:${2:model}_detail}", kwargs={"${3|pk,slug|}": self.$3})
"""
[[snippets]]
prefix = "receiver"
body = """
@receiver($2, sender=${3:Model})
def $1_${2|post_save,pre_init,post_init,pre_save,pre_delete,post_delete,m2m_changed,class_prepared,pre_migrate,post_migrate|}_receiver(sender, **kwargs):
$0
"""

View File

@ -1,169 +0,0 @@
[[snippets]]
prefix = "run_python_function"
body = """
def $1(apps, schema_editor):
${2:Model} = apps.get_model("${3:${TM_FILEPATH/.*[\\/](\w+)[\\/]migrations.*/$1/g}}", "$2")$0
"""
[[snippets]]
prefix = "create_model"
body = """
migrations.CreateModel(
name='$1',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),$3
],
options={
'verbose_name': '$1',
'verbose_name_plural': '$1s$2',
}
)$0
"""
[[snippets]]
prefix = "delete_model"
body = """
migrations.DeleteModel(
name="$1",
)$0
"""
[[snippets]]
prefix = "rename_model"
body = """
migrations.RenameModel(
old_name=$1,
new_name=$2,
)$0
"""
[[snippets]]
prefix = "alter_model_table"
body = """
migrations.AlterModelTable(
name="$1",
table="$2",
)$0
"""
[[snippets]]
prefix = "alter_unique_together"
body = """
migrations.AlterUniqueTogether(
name="$1",
unique_together=("$2", "$3"),
)$0
"""
[[snippets]]
prefix = "alter_index_together"
body = """
migrations.AlterIndexTogether(
name="$1",
index_together=("$2", "$3"),
)$0
"""
[[snippets]]
prefix = "alter_order_with_respect_to"
body = """
migrations.AlterOrderWithRespectTo(
name="$1",
order_with_respect_to=$2,
)$0
"""
[[snippets]]
prefix = "alter_model_options"
body = """
migrations.AlterModelOptions(
name="$1",
options={$2},
)$0
"""
[[snippets]]
prefix = "alter_model_managers"
body = """
migrations.AlterModelManagers(
name="$1",
managers=$2,
)$0
"""
[[snippets]]
prefix = "add_field"
body = """
migrations.AddField(
model_name="$1",
name="$2",
field=$3,
)$0
"""
[[snippets]]
prefix = "remove_field"
body = """
migrations.RemoveField(
model_name="$1",
name="$2",
)$0
"""
[[snippets]]
prefix = "alter_field"
body = """
migrations.AlterField(
model_name="$1",
name="$2",
field=$3,
)$0
"""
[[snippets]]
prefix = "rename_field"
body = """
migrations.RenameField(
model_name="$1",
old_name="$2",
new_name="$3",
)$0
"""
[[snippets]]
prefix = "add_index"
body = """
migrations.AddIndex(
model_name="$1",
index="$2",
)$0
"""
[[snippets]]
prefix = "remove_index"
body = """
migrations.RemoveIndex(
model_name="$1",
name="$2",
)$0
"""
[[snippets]]
prefix = "run_sql"
body = "migrations.RunSQL($1)"
[[snippets]]
prefix = "run_python"
detail = "migrations.RunPython()"
description = "migrations.RunPython(forward, backward)"
body = "migrations.RunPython($1${2:, ${3:migrations.RunPython.noop}}),"
[[snippets]]
prefix = "separate_database_and_state"
body = """
migrations.SeparateDatabaseAndState(
database_operations=${1:None},
state_operations=${2:None},
)
"""

View File

@ -1,25 +0,0 @@
[[snippets]]
prefix = "from_conf_import_settings"
detail = "from django.conf import settings"
body = "from django.conf import settings"
[[snippets]]
prefix = "from_trans_import_gettext"
detail = "import gettext"
body = "from django.utils.translation import ${1|ugettext_lazy,ugettext,gettext_lazy,gettext|} as _"
[[snippets]]
prefix = "from_trans_import_ugettext_lazy"
detail = "import ugettext_lazy as _"
body = "from django.utils.translation import ugettext_lazy as _"
[[snippets]]
prefix = "from_trans_import_ngettext"
detail = "import ngettext (plural)"
body = "from django.utils.translation import ${1|ungettext,ngettext,npgettext|}"
[[snippets]]
prefix = "from_trans_import_pgettext"
detail = "import pgettext (context)"
body = "from django.utils.translation import ${1|pgettext_lazy,pgettext,npgettext|}"

View File

@ -1,23 +0,0 @@
[[snippets]]
prefix = "args"
detail = "*args"
body = "*args"
[[snippets]]
prefix = "args_kwargs"
detail = "*args, **kwargs"
body = "*args, **kwargs"
[[snippets]]
prefix = "method"
detail = "def method(self, *args, **kwargs):"
description = """```python
def method(self, *args, **kwargs):
return super().method(*args, **kwargs)
```
"""
body = """
$1(self, $2*args, **kwargs):
${3:return} super().$1($2*args, **kwargs)$0
"""

View File

@ -1,15 +0,0 @@
[[snippets]]
prefix = "import_library_register"
detail = "register = template.Library()"
description = """```python
from django import template
register = template.Library()
```
"""
body = """
from django import template
register = template.Library()$0
"""

View File

@ -1,39 +0,0 @@
[[snippets]]
prefix = "register_assignment_tag"
body = """
def get_$1(context):
request = context.get("request")
$1 = ${2:[]}
return ${3:$1}"
"""
[[snippets]]
prefix = "register_filter"
body = """
@register.filter
def $1(value):
return value$2
"""
[[snippets]]
prefix = "register_inclusion_tag"
body = """
@register.inclusion_tag(${1:"$2.html"}, takes_context=True)
def $1(context):
request = context.get("request")
$3
return {
"request": request,
$4
}
"""
[[snippets]]
prefix = "register_simple_tag"
body = """
@register.simple_tag(takes_context=True)
def $1(context):
request = context.get("request")
return ${2:"It Works!"}
"""

View File

@ -1,20 +0,0 @@
[[snippets]]
prefix = "from_urls_import_reverse"
body = "from django.urls import ${1|reverse,reverse_lazy,resolve,get_script_prefix|}"
detail = "import reverse, resolve…"
[[snippets]]
prefix = "from_urls_import_url"
body = "from django.conf.urls import ${1|url,include,static|}"
detail = "import url, include…"
[[snippets]]
prefix = "from_urls_import_handler"
body = "from django.conf.urls import ${1|handler400,handler403,handler404,handler500|}"
detail = "import handler404…"
[[snippets]]
prefix = "from_urls_import_path"
body = "from django.urls import ${1|path,re_path,include,reverse,reverse_lazy,static,register_converter|}"
detail = "import path, path_re…"

View File

@ -1,42 +0,0 @@
[[snippets]]
prefix = "url_stack"
body = """
${1|url,re_path|}(
r"^$2/$",
$3${4:.as_view()},
name="$5"
)
"""
[[snippets]]
prefix = "url_inline"
body = """
${1|url,re_path|}(r"^$2/$", $3${4:.as_view()}, name="$5"),
"""
detail = """url(r"^/$", View.as_view(), name="")"""
[[snippets]]
prefix = "path_stack"
body = """
path(
"$1/",
${2:VIEW}${3:.as_view()},
name="$4"
)
"""
description = "path(route, view, kwargs=None, name=None)"
[[snippets]]
prefix = "path_inline"
body = """path("$1/", $2${3:.as_view()}, name="$4")"""
description = "path(route, view, kwargs=None, name=None)"
[[snippets]]
prefix = "urlpatterns"
body = """
urlpatterns = [
$0
]
"""
detail = "urlpatterns = []"

View File

@ -1,30 +0,0 @@
[[snippets]]
prefix = "regex_pk"
body = '''r"^$1(?P<${2:pk}>\d+)/$"'''
detail = '''r"^(?P<pk>\d+)/$"'''
[[snippets]]
prefix = "regex_slug"
body = '''r"^$1(?P<${2:slug}>[-\w]+)/$"'''
detail = '''r"^(?P<slug>[-\w]+)/$"'''
[[snippets]]
prefix = "path_str"
body = "<str:$1>"
[[snippets]]
prefix = "path_int"
body = "<int:$1>"
[[snippets]]
prefix = "path_slug"
body = "<slug:$1>"
[[snippets]]
prefix = "path_uuid"
body = "<uuid:$1>"
[[snippets]]
prefix = "path_path"
body = "<path:$1>"

View File

@ -1,53 +0,0 @@
[[snippets]]
prefix = "class_createview"
detail = "class ModelCreateView(CreateView)"
body = """
class ${1:Model}CreateView(CreateView):
model = $1
template_name = "$2.html"$0
"""
[[snippets]]
prefix = "class_deleteview"
detail = "class ModelDeleteView(DeleteView)"
body = """
class ${1:Model}DeleteView(DeleteView):
model = $1
template_name = "$2.html"$0
"""
[[snippets]]
prefix = "class_detailview"
detail = "class ModelDetailView(DetailView)"
body = """
class ${1:Model}DetailView(DetailView):
model = $1
template_name = "$2.html"$0
"""
[[snippets]]
prefix = "class_listview"
detail = "class ModelListView(ListView)"
body = """
class ${1:Model}ListView(ListView):
model = $1
template_name = "$2.html"$0
"""
[[snippets]]
prefix = "class_templateview"
detail = "class ModelView(TemplateView)"
body = """
class ${1:Model}View(TemplateView):
template_name = "$2.html"$0
"""
[[snippets]]
prefix = "class_updateview"
detail = "class ModelUpdateView(UpdateView)"
body = """
class ${1:Model}UpdateView(UpdateView):
model = $1
template_name = "$2.html"$0
"""

View File

@ -1,10 +0,0 @@
[[snippets]]
prefix = "from_views_import"
detail = ""
body = "from .views import $1"
[[snippets]]
prefix = "from_generic_import_views"
detail = "Generic class-based views"
body = "from django.views.generic import ${1|CreateView,DetailView,FormView,ListView,TemplateView,UpdateView|}"

View File

@ -1,54 +0,0 @@
[[snippets]]
prefix = "dispatch"
detail = "dispatch(self, request, *args, **kwargs)"
body = """
def dispatch(self, request, *args, **kwargs):
return super().dispatch(request, *args, **kwargs)
"""
[[snippets]]
prefix = "get_context_data"
detail = "get_context_data(self, **kwargs)"
body = """
def get_context_data(self, **kwargs) -> dict[str, Any]:
context = super().get_context_data(**kwargs)
context["$1"] = $2
return context
"""
[[snippets]]
prefix = "get_queryset"
detail = "get_queryset(self)"
body = """
def get_queryset(self):
${1:return} super().get_queryset()$0
"""
[[snippets]]
prefix = "get_template_names"
detail = "get_template_names(self)"
body = """
def get_template_names(self) -> list[str]:
if ${1:condition}:
return ["$2"]
return super().get_template_names()
"""
[[snippets]]
prefix = "form_valid"
detail = "form_valid(self, form)"
body = """
def form_valid(self, form):
${1:form}
return super().form_valid(form)
"""
[[snippets]]
prefix = "form_invalid"
detail = "form_invalid(self, form)"
body = """
def form_invalid(self, form):
response = super().form_invalid(form)
${1:response}
"""

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.3 KiB

View File

@ -1,6 +0,0 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256">
<circle r="128" cy="128" cx="128" id="path37" style="fill:#ffffff" />
<path id="d" style="fill:#44b78b" d="m 108,40 h 32 v 147.6 c -13.6,2.7 -27.4,4.2 -41.3,4.3 C 59.7,191.9 40,174.5 40,141.1 40,109.0 60.9,86.4 94.2,86.4 c 4.6,-0.0 9.2,0.4 13.7,1.6 z m 0.1,73.4 c -3.4,-1.1 -7.1,-1.6 -10.7,-1.6 -16.0,0 -25.4,11.4 -25.4,28.6 0,16.7 8.8,26.0 25.2,26.0 3.6,0 7.1,-0.2 10.8,-0.8 v -52.2 z" />
<path id="j" style="fill:#44b78b" d="m 192,88 v 73.1 c 0,25.1 -1.8,37.2 -7.4,47.7 C 178.9,219.5 169.1,227.5 158,232 l -30,-14 c 10.7,-3.6 20.7,-10.9 26.2,-20.8 C 158.7,188.1 160,177.7 160,150.2 V 88 Z" />
<rect id="dot" style="fill:#44b78b" height="32" width="32" y="40" x="160" />
</svg>

Before

Width:  |  Height:  |  Size: 749 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 152 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 155 KiB

View File

@ -1,63 +0,0 @@
{
"comments": {
// symbols used for start and end a block comment. Remove this entry if your language does not support block comments
"blockComment": [ "{% comment %}", "{% endcomment %}" ]
},
// symbols used as brackets
"brackets": [
["<!--", "-->"],
["<", ">"],
["{", "}"],
["{{", "}}"],
["{%", "%}"],
["{#", "#}"],
["(", ")"]
],
// symbols that are auto closed when typing
"autoClosingPairs": [
{ "open": "{", "close": "}"},
{ "open": "%", "close": "%", "notIn": [ "comment", "string" ]},
{ "open": "[", "close": "]"},
{ "open": "(", "close": ")" },
{ "open": "'", "close": "'" },
{ "open": "`", "close": "`" },
{ "open": "\"", "close": "\"" },
{ "open": "<!--", "close": "-->", "notIn": [ "comment", "string" ]}
],
// symbols that that can be used to surround a selection
"surroundingPairs": [
{ "open": "'", "close": "'" },
{ "open": "\"", "close": "\"" },
{ "open": "{", "close": "}"},
{ "open": "%", "close": "%"},
{ "open": "[", "close": "]"},
{ "open": "(", "close": ")" },
{ "open": "<", "close": ">" }
],
"folding": {
"markers": {
"start": "^\\s*<!--\\s*#region\\b.*-->",
"end": "^\\s*<!--\\s*#endregion\\b.*-->"
}
},
"wordPattern": "([\\w\\/\\.]+)|(-?\\d*\\.\\d\\w*)|([^\\`\\~\\!\\@\\#\\%\\^\\&\\*\\(\\)\\-\\=\\+\\[\\{\\]\\}\\\\\\|\\;\\:\\'\\\"\\,\\.\\<\\>\\/\\?\\s]+)",
"onEnterRules": [
{
"beforeText": { "pattern": "<(?!(?:area|base|br|col|embed|hr|img|input|keygen|link|menuitem|meta|param|source|track|wbr))([_:\\w][_:\\w-.\\d]*)(?:(?:[^'\"/>]|\"[^\"]*\"|'[^']*')*?(?!\\/)>)[^<]*$", "flags": "i" },
"afterText": { "pattern": "^<\\/([_:\\w][_:\\w-.\\d]*)\\s*>", "flags": "i" },
"action": {
"indent": "indentOutdent"
}
},
{
"beforeText": { "pattern": "<(?!(?:area|base|br|col|embed|hr|img|input|keygen|link|menuitem|meta|param|source|track|wbr))([_:\\w][_:\\w-.\\d]*)(?:(?:[^'\"/>]|\"[^\"]*\"|'[^']*')*?(?!\\/)>)[^<]*$", "flags": "i" },
"action": {
"indent": "indent"
}
}
],
"indentationRules": {
"increaseIndentPattern": "<(?!\\?|(?:area|base|br|col|frame|hr|html|img|input|keygen|link|menuitem|meta|param|source|track|wbr)\\b|[^>]*\\/>)([-_\\.A-Za-z0-9]+)(?=\\s|>)\\b[^>]*>(?!.*<\\/\\1>)|<!--(?!.*-->)|\\{[^}\"']*$",
"decreaseIndentPattern": "^\\s*(<\\/(?!html)[-_\\.A-Za-z0-9]+\\b[^>]*>|-->|\\})"
}
}

View File

@ -1,16 +0,0 @@
The ISC License
Copyright (c) Isaac Z. Schlueter
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.

View File

@ -1,42 +0,0 @@
Browser-friendly inheritance fully compatible with standard node.js
[inherits](http://nodejs.org/api/util.html#util_util_inherits_constructor_superconstructor).
This package exports standard `inherits` from node.js `util` module in
node environment, but also provides alternative browser-friendly
implementation through [browser
field](https://gist.github.com/shtylman/4339901). Alternative
implementation is a literal copy of standard one located in standalone
module to avoid requiring of `util`. It also has a shim for old
browsers with no `Object.create` support.
While keeping you sure you are using standard `inherits`
implementation in node.js environment, it allows bundlers such as
[browserify](https://github.com/substack/node-browserify) to not
include full `util` package to your client code if all you need is
just `inherits` function. It worth, because browser shim for `util`
package is large and `inherits` is often the single function you need
from it.
It's recommended to use this package instead of
`require('util').inherits` for any code that has chances to be used
not only in node.js but in browser too.
## usage
```js
var inherits = require('inherits');
// then use exactly as the standard one
```
## note on version ~1.0
Version ~1.0 had completely different motivation and is not compatible
neither with 2.0 nor with standard node.js `inherits`.
If you are using version ~1.0 and planning to switch to ~2.0, be
careful:
* new version uses `super_` instead of `super` for referencing
superclass
* new version overwrites current prototype while old one preserves any
existing fields on it

View File

@ -1,9 +0,0 @@
try {
var util = require('util');
/* istanbul ignore next */
if (typeof util.inherits !== 'function') throw '';
module.exports = util.inherits;
} catch (e) {
/* istanbul ignore next */
module.exports = require('./inherits_browser.js');
}

View File

@ -1,27 +0,0 @@
if (typeof Object.create === 'function') {
// implementation from standard node.js 'util' module
module.exports = function inherits(ctor, superCtor) {
if (superCtor) {
ctor.super_ = superCtor
ctor.prototype = Object.create(superCtor.prototype, {
constructor: {
value: ctor,
enumerable: false,
writable: true,
configurable: true
}
})
}
};
} else {
// old school shim for old browsers
module.exports = function inherits(ctor, superCtor) {
if (superCtor) {
ctor.super_ = superCtor
var TempCtor = function () {}
TempCtor.prototype = superCtor.prototype
ctor.prototype = new TempCtor()
ctor.prototype.constructor = ctor
}
}
}

View File

@ -1,29 +0,0 @@
{
"name": "inherits",
"description": "Browser-friendly inheritance fully compatible with standard node.js inherits()",
"version": "2.0.4",
"keywords": [
"inheritance",
"class",
"klass",
"oop",
"object-oriented",
"inherits",
"browser",
"browserify"
],
"main": "./inherits.js",
"browser": "./inherits_browser.js",
"repository": "git://github.com/isaacs/inherits",
"license": "ISC",
"scripts": {
"test": "tap"
},
"devDependencies": {
"tap": "^14.2.4"
},
"files": [
"inherits.js",
"inherits_browser.js"
]
}

View File

@ -1 +0,0 @@
node_modules

View File

@ -1,18 +0,0 @@
Copyright Joyent, Inc. and other Node contributors. All rights reserved.
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.

View File

@ -1,15 +0,0 @@
# path
This is an exact copy of the NodeJS path module published to the NPM registry.
[Documentation](http://nodejs.org/docs/latest/api/path.html)
## Install
```sh
$ npm install --save path
```
## License
MIT

View File

@ -1,24 +0,0 @@
{
"author": {
"name": "Joyent",
"url": "http://www.joyent.com"
},
"name": "path",
"description": "Node.JS path module",
"keywords": [
"ender",
"path"
],
"license": "MIT",
"version": "0.12.7",
"homepage": "http://nodejs.org/docs/latest/api/path.html",
"repository": {
"type": "git",
"url": "git://github.com/jinder/path.git"
},
"main": "./path.js",
"dependencies": {
"process": "^0.11.1",
"util": "^0.10.3"
}
}

View File

@ -1,628 +0,0 @@
// Copyright Joyent, Inc. and other Node contributors.
//
// 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.
'use strict';
var isWindows = process.platform === 'win32';
var util = require('util');
// resolves . and .. elements in a path array with directory names there
// must be no slashes or device names (c:\) in the array
// (so also no leading and trailing slashes - it does not distinguish
// relative and absolute paths)
function normalizeArray(parts, allowAboveRoot) {
var res = [];
for (var i = 0; i < parts.length; i++) {
var p = parts[i];
// ignore empty parts
if (!p || p === '.')
continue;
if (p === '..') {
if (res.length && res[res.length - 1] !== '..') {
res.pop();
} else if (allowAboveRoot) {
res.push('..');
}
} else {
res.push(p);
}
}
return res;
}
// returns an array with empty elements removed from either end of the input
// array or the original array if no elements need to be removed
function trimArray(arr) {
var lastIndex = arr.length - 1;
var start = 0;
for (; start <= lastIndex; start++) {
if (arr[start])
break;
}
var end = lastIndex;
for (; end >= 0; end--) {
if (arr[end])
break;
}
if (start === 0 && end === lastIndex)
return arr;
if (start > end)
return [];
return arr.slice(start, end + 1);
}
// Regex to split a windows path into three parts: [*, device, slash,
// tail] windows-only
var splitDeviceRe =
/^([a-zA-Z]:|[\\\/]{2}[^\\\/]+[\\\/]+[^\\\/]+)?([\\\/])?([\s\S]*?)$/;
// Regex to split the tail part of the above into [*, dir, basename, ext]
var splitTailRe =
/^([\s\S]*?)((?:\.{1,2}|[^\\\/]+?|)(\.[^.\/\\]*|))(?:[\\\/]*)$/;
var win32 = {};
// Function to split a filename into [root, dir, basename, ext]
function win32SplitPath(filename) {
// Separate device+slash from tail
var result = splitDeviceRe.exec(filename),
device = (result[1] || '') + (result[2] || ''),
tail = result[3] || '';
// Split the tail into dir, basename and extension
var result2 = splitTailRe.exec(tail),
dir = result2[1],
basename = result2[2],
ext = result2[3];
return [device, dir, basename, ext];
}
function win32StatPath(path) {
var result = splitDeviceRe.exec(path),
device = result[1] || '',
isUnc = !!device && device[1] !== ':';
return {
device: device,
isUnc: isUnc,
isAbsolute: isUnc || !!result[2], // UNC paths are always absolute
tail: result[3]
};
}
function normalizeUNCRoot(device) {
return '\\\\' + device.replace(/^[\\\/]+/, '').replace(/[\\\/]+/g, '\\');
}
// path.resolve([from ...], to)
win32.resolve = function() {
var resolvedDevice = '',
resolvedTail = '',
resolvedAbsolute = false;
for (var i = arguments.length - 1; i >= -1; i--) {
var path;
if (i >= 0) {
path = arguments[i];
} else if (!resolvedDevice) {
path = process.cwd();
} else {
// Windows has the concept of drive-specific current working
// directories. If we've resolved a drive letter but not yet an
// absolute path, get cwd for that drive. We're sure the device is not
// an unc path at this points, because unc paths are always absolute.
path = process.env['=' + resolvedDevice];
// Verify that a drive-local cwd was found and that it actually points
// to our drive. If not, default to the drive's root.
if (!path || path.substr(0, 3).toLowerCase() !==
resolvedDevice.toLowerCase() + '\\') {
path = resolvedDevice + '\\';
}
}
// Skip empty and invalid entries
if (!util.isString(path)) {
throw new TypeError('Arguments to path.resolve must be strings');
} else if (!path) {
continue;
}
var result = win32StatPath(path),
device = result.device,
isUnc = result.isUnc,
isAbsolute = result.isAbsolute,
tail = result.tail;
if (device &&
resolvedDevice &&
device.toLowerCase() !== resolvedDevice.toLowerCase()) {
// This path points to another device so it is not applicable
continue;
}
if (!resolvedDevice) {
resolvedDevice = device;
}
if (!resolvedAbsolute) {
resolvedTail = tail + '\\' + resolvedTail;
resolvedAbsolute = isAbsolute;
}
if (resolvedDevice && resolvedAbsolute) {
break;
}
}
// Convert slashes to backslashes when `resolvedDevice` points to an UNC
// root. Also squash multiple slashes into a single one where appropriate.
if (isUnc) {
resolvedDevice = normalizeUNCRoot(resolvedDevice);
}
// At this point the path should be resolved to a full absolute path,
// but handle relative paths to be safe (might happen when process.cwd()
// fails)
// Normalize the tail path
resolvedTail = normalizeArray(resolvedTail.split(/[\\\/]+/),
!resolvedAbsolute).join('\\');
return (resolvedDevice + (resolvedAbsolute ? '\\' : '') + resolvedTail) ||
'.';
};
win32.normalize = function(path) {
var result = win32StatPath(path),
device = result.device,
isUnc = result.isUnc,
isAbsolute = result.isAbsolute,
tail = result.tail,
trailingSlash = /[\\\/]$/.test(tail);
// Normalize the tail path
tail = normalizeArray(tail.split(/[\\\/]+/), !isAbsolute).join('\\');
if (!tail && !isAbsolute) {
tail = '.';
}
if (tail && trailingSlash) {
tail += '\\';
}
// Convert slashes to backslashes when `device` points to an UNC root.
// Also squash multiple slashes into a single one where appropriate.
if (isUnc) {
device = normalizeUNCRoot(device);
}
return device + (isAbsolute ? '\\' : '') + tail;
};
win32.isAbsolute = function(path) {
return win32StatPath(path).isAbsolute;
};
win32.join = function() {
var paths = [];
for (var i = 0; i < arguments.length; i++) {
var arg = arguments[i];
if (!util.isString(arg)) {
throw new TypeError('Arguments to path.join must be strings');
}
if (arg) {
paths.push(arg);
}
}
var joined = paths.join('\\');
// Make sure that the joined path doesn't start with two slashes, because
// normalize() will mistake it for an UNC path then.
//
// This step is skipped when it is very clear that the user actually
// intended to point at an UNC path. This is assumed when the first
// non-empty string arguments starts with exactly two slashes followed by
// at least one more non-slash character.
//
// Note that for normalize() to treat a path as an UNC path it needs to
// have at least 2 components, so we don't filter for that here.
// This means that the user can use join to construct UNC paths from
// a server name and a share name; for example:
// path.join('//server', 'share') -> '\\\\server\\share\')
if (!/^[\\\/]{2}[^\\\/]/.test(paths[0])) {
joined = joined.replace(/^[\\\/]{2,}/, '\\');
}
return win32.normalize(joined);
};
// path.relative(from, to)
// it will solve the relative path from 'from' to 'to', for instance:
// from = 'C:\\orandea\\test\\aaa'
// to = 'C:\\orandea\\impl\\bbb'
// The output of the function should be: '..\\..\\impl\\bbb'
win32.relative = function(from, to) {
from = win32.resolve(from);
to = win32.resolve(to);
// windows is not case sensitive
var lowerFrom = from.toLowerCase();
var lowerTo = to.toLowerCase();
var toParts = trimArray(to.split('\\'));
var lowerFromParts = trimArray(lowerFrom.split('\\'));
var lowerToParts = trimArray(lowerTo.split('\\'));
var length = Math.min(lowerFromParts.length, lowerToParts.length);
var samePartsLength = length;
for (var i = 0; i < length; i++) {
if (lowerFromParts[i] !== lowerToParts[i]) {
samePartsLength = i;
break;
}
}
if (samePartsLength == 0) {
return to;
}
var outputParts = [];
for (var i = samePartsLength; i < lowerFromParts.length; i++) {
outputParts.push('..');
}
outputParts = outputParts.concat(toParts.slice(samePartsLength));
return outputParts.join('\\');
};
win32._makeLong = function(path) {
// Note: this will *probably* throw somewhere.
if (!util.isString(path))
return path;
if (!path) {
return '';
}
var resolvedPath = win32.resolve(path);
if (/^[a-zA-Z]\:\\/.test(resolvedPath)) {
// path is local filesystem path, which needs to be converted
// to long UNC path.
return '\\\\?\\' + resolvedPath;
} else if (/^\\\\[^?.]/.test(resolvedPath)) {
// path is network UNC path, which needs to be converted
// to long UNC path.
return '\\\\?\\UNC\\' + resolvedPath.substring(2);
}
return path;
};
win32.dirname = function(path) {
var result = win32SplitPath(path),
root = result[0],
dir = result[1];
if (!root && !dir) {
// No dirname whatsoever
return '.';
}
if (dir) {
// It has a dirname, strip trailing slash
dir = dir.substr(0, dir.length - 1);
}
return root + dir;
};
win32.basename = function(path, ext) {
var f = win32SplitPath(path)[2];
// TODO: make this comparison case-insensitive on windows?
if (ext && f.substr(-1 * ext.length) === ext) {
f = f.substr(0, f.length - ext.length);
}
return f;
};
win32.extname = function(path) {
return win32SplitPath(path)[3];
};
win32.format = function(pathObject) {
if (!util.isObject(pathObject)) {
throw new TypeError(
"Parameter 'pathObject' must be an object, not " + typeof pathObject
);
}
var root = pathObject.root || '';
if (!util.isString(root)) {
throw new TypeError(
"'pathObject.root' must be a string or undefined, not " +
typeof pathObject.root
);
}
var dir = pathObject.dir;
var base = pathObject.base || '';
if (!dir) {
return base;
}
if (dir[dir.length - 1] === win32.sep) {
return dir + base;
}
return dir + win32.sep + base;
};
win32.parse = function(pathString) {
if (!util.isString(pathString)) {
throw new TypeError(
"Parameter 'pathString' must be a string, not " + typeof pathString
);
}
var allParts = win32SplitPath(pathString);
if (!allParts || allParts.length !== 4) {
throw new TypeError("Invalid path '" + pathString + "'");
}
return {
root: allParts[0],
dir: allParts[0] + allParts[1].slice(0, -1),
base: allParts[2],
ext: allParts[3],
name: allParts[2].slice(0, allParts[2].length - allParts[3].length)
};
};
win32.sep = '\\';
win32.delimiter = ';';
// Split a filename into [root, dir, basename, ext], unix version
// 'root' is just a slash, or nothing.
var splitPathRe =
/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/;
var posix = {};
function posixSplitPath(filename) {
return splitPathRe.exec(filename).slice(1);
}
// path.resolve([from ...], to)
// posix version
posix.resolve = function() {
var resolvedPath = '',
resolvedAbsolute = false;
for (var i = arguments.length - 1; i >= -1 && !resolvedAbsolute; i--) {
var path = (i >= 0) ? arguments[i] : process.cwd();
// Skip empty and invalid entries
if (!util.isString(path)) {
throw new TypeError('Arguments to path.resolve must be strings');
} else if (!path) {
continue;
}
resolvedPath = path + '/' + resolvedPath;
resolvedAbsolute = path[0] === '/';
}
// At this point the path should be resolved to a full absolute path, but
// handle relative paths to be safe (might happen when process.cwd() fails)
// Normalize the path
resolvedPath = normalizeArray(resolvedPath.split('/'),
!resolvedAbsolute).join('/');
return ((resolvedAbsolute ? '/' : '') + resolvedPath) || '.';
};
// path.normalize(path)
// posix version
posix.normalize = function(path) {
var isAbsolute = posix.isAbsolute(path),
trailingSlash = path && path[path.length - 1] === '/';
// Normalize the path
path = normalizeArray(path.split('/'), !isAbsolute).join('/');
if (!path && !isAbsolute) {
path = '.';
}
if (path && trailingSlash) {
path += '/';
}
return (isAbsolute ? '/' : '') + path;
};
// posix version
posix.isAbsolute = function(path) {
return path.charAt(0) === '/';
};
// posix version
posix.join = function() {
var path = '';
for (var i = 0; i < arguments.length; i++) {
var segment = arguments[i];
if (!util.isString(segment)) {
throw new TypeError('Arguments to path.join must be strings');
}
if (segment) {
if (!path) {
path += segment;
} else {
path += '/' + segment;
}
}
}
return posix.normalize(path);
};
// path.relative(from, to)
// posix version
posix.relative = function(from, to) {
from = posix.resolve(from).substr(1);
to = posix.resolve(to).substr(1);
var fromParts = trimArray(from.split('/'));
var toParts = trimArray(to.split('/'));
var length = Math.min(fromParts.length, toParts.length);
var samePartsLength = length;
for (var i = 0; i < length; i++) {
if (fromParts[i] !== toParts[i]) {
samePartsLength = i;
break;
}
}
var outputParts = [];
for (var i = samePartsLength; i < fromParts.length; i++) {
outputParts.push('..');
}
outputParts = outputParts.concat(toParts.slice(samePartsLength));
return outputParts.join('/');
};
posix._makeLong = function(path) {
return path;
};
posix.dirname = function(path) {
var result = posixSplitPath(path),
root = result[0],
dir = result[1];
if (!root && !dir) {
// No dirname whatsoever
return '.';
}
if (dir) {
// It has a dirname, strip trailing slash
dir = dir.substr(0, dir.length - 1);
}
return root + dir;
};
posix.basename = function(path, ext) {
var f = posixSplitPath(path)[2];
// TODO: make this comparison case-insensitive on windows?
if (ext && f.substr(-1 * ext.length) === ext) {
f = f.substr(0, f.length - ext.length);
}
return f;
};
posix.extname = function(path) {
return posixSplitPath(path)[3];
};
posix.format = function(pathObject) {
if (!util.isObject(pathObject)) {
throw new TypeError(
"Parameter 'pathObject' must be an object, not " + typeof pathObject
);
}
var root = pathObject.root || '';
if (!util.isString(root)) {
throw new TypeError(
"'pathObject.root' must be a string or undefined, not " +
typeof pathObject.root
);
}
var dir = pathObject.dir ? pathObject.dir + posix.sep : '';
var base = pathObject.base || '';
return dir + base;
};
posix.parse = function(pathString) {
if (!util.isString(pathString)) {
throw new TypeError(
"Parameter 'pathString' must be a string, not " + typeof pathString
);
}
var allParts = posixSplitPath(pathString);
if (!allParts || allParts.length !== 4) {
throw new TypeError("Invalid path '" + pathString + "'");
}
allParts[1] = allParts[1] || '';
allParts[2] = allParts[2] || '';
allParts[3] = allParts[3] || '';
return {
root: allParts[0],
dir: allParts[0] + allParts[1].slice(0, -1),
base: allParts[2],
ext: allParts[3],
name: allParts[2].slice(0, allParts[2].length - allParts[3].length)
};
};
posix.sep = '/';
posix.delimiter = ':';
if (isWindows)
module.exports = win32;
else /* posix */
module.exports = posix;
module.exports.posix = posix;
module.exports.win32 = win32;

View File

@ -1,21 +0,0 @@
{
extends: "eslint:recommended",
"env": {
"node": true,
"browser": true,
"es6" : true,
"mocha": true
},
"rules": {
"indent": [2, 4],
"brace-style": [2, "1tbs"],
"quotes": [2, "single"],
"no-console": 0,
"no-shadow": 0,
"no-use-before-define": [2, "nofunc"],
"no-underscore-dangle": 0,
"no-constant-condition": 0,
"space-after-function-name": 0,
"consistent-return": 0
}
}

View File

@ -1,22 +0,0 @@
(The MIT License)
Copyright (c) 2013 Roman Shtylman <shtylman@gmail.com>
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.

View File

@ -1,26 +0,0 @@
# process
```require('process');``` just like any other module.
Works in node.js and browsers via the browser.js shim provided with the module.
## browser implementation
The goal of this module is not to be a full-fledged alternative to the builtin process module. This module mostly exists to provide the nextTick functionality and little more. We keep this module lean because it will often be included by default by tools like browserify when it detects a module has used the `process` global.
It also exposes a "browser" member (i.e. `process.browser`) which is `true` in this implementation but `undefined` in node. This can be used in isomorphic code that adjusts it's behavior depending on which environment it's running in.
If you are looking to provide other process methods, I suggest you monkey patch them onto the process global in your app. A list of user created patches is below.
* [hrtime](https://github.com/kumavis/browser-process-hrtime)
* [stdout](https://github.com/kumavis/browser-stdout)
## package manager notes
If you are writing a bundler to package modules for client side use, make sure you use the ```browser``` field hint in package.json.
See https://gist.github.com/4339901 for details.
The [browserify](https://github.com/substack/node-browserify) module will properly handle this field when bundling your files.

View File

@ -1,184 +0,0 @@
// shim for using process in browser
var process = module.exports = {};
// cached from whatever global is present so that test runners that stub it
// don't break things. But we need to wrap it in a try catch in case it is
// wrapped in strict mode code which doesn't define any globals. It's inside a
// function because try/catches deoptimize in certain engines.
var cachedSetTimeout;
var cachedClearTimeout;
function defaultSetTimout() {
throw new Error('setTimeout has not been defined');
}
function defaultClearTimeout () {
throw new Error('clearTimeout has not been defined');
}
(function () {
try {
if (typeof setTimeout === 'function') {
cachedSetTimeout = setTimeout;
} else {
cachedSetTimeout = defaultSetTimout;
}
} catch (e) {
cachedSetTimeout = defaultSetTimout;
}
try {
if (typeof clearTimeout === 'function') {
cachedClearTimeout = clearTimeout;
} else {
cachedClearTimeout = defaultClearTimeout;
}
} catch (e) {
cachedClearTimeout = defaultClearTimeout;
}
} ())
function runTimeout(fun) {
if (cachedSetTimeout === setTimeout) {
//normal enviroments in sane situations
return setTimeout(fun, 0);
}
// if setTimeout wasn't available but was latter defined
if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
cachedSetTimeout = setTimeout;
return setTimeout(fun, 0);
}
try {
// when when somebody has screwed with setTimeout but no I.E. maddness
return cachedSetTimeout(fun, 0);
} catch(e){
try {
// When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
return cachedSetTimeout.call(null, fun, 0);
} catch(e){
// same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error
return cachedSetTimeout.call(this, fun, 0);
}
}
}
function runClearTimeout(marker) {
if (cachedClearTimeout === clearTimeout) {
//normal enviroments in sane situations
return clearTimeout(marker);
}
// if clearTimeout wasn't available but was latter defined
if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
cachedClearTimeout = clearTimeout;
return clearTimeout(marker);
}
try {
// when when somebody has screwed with setTimeout but no I.E. maddness
return cachedClearTimeout(marker);
} catch (e){
try {
// When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
return cachedClearTimeout.call(null, marker);
} catch (e){
// same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error.
// Some versions of I.E. have different rules for clearTimeout vs setTimeout
return cachedClearTimeout.call(this, marker);
}
}
}
var queue = [];
var draining = false;
var currentQueue;
var queueIndex = -1;
function cleanUpNextTick() {
if (!draining || !currentQueue) {
return;
}
draining = false;
if (currentQueue.length) {
queue = currentQueue.concat(queue);
} else {
queueIndex = -1;
}
if (queue.length) {
drainQueue();
}
}
function drainQueue() {
if (draining) {
return;
}
var timeout = runTimeout(cleanUpNextTick);
draining = true;
var len = queue.length;
while(len) {
currentQueue = queue;
queue = [];
while (++queueIndex < len) {
if (currentQueue) {
currentQueue[queueIndex].run();
}
}
queueIndex = -1;
len = queue.length;
}
currentQueue = null;
draining = false;
runClearTimeout(timeout);
}
process.nextTick = function (fun) {
var args = new Array(arguments.length - 1);
if (arguments.length > 1) {
for (var i = 1; i < arguments.length; i++) {
args[i - 1] = arguments[i];
}
}
queue.push(new Item(fun, args));
if (queue.length === 1 && !draining) {
runTimeout(drainQueue);
}
};
// v8 likes predictible objects
function Item(fun, array) {
this.fun = fun;
this.array = array;
}
Item.prototype.run = function () {
this.fun.apply(null, this.array);
};
process.title = 'browser';
process.browser = true;
process.env = {};
process.argv = [];
process.version = ''; // empty string to avoid regexp issues
process.versions = {};
function noop() {}
process.on = noop;
process.addListener = noop;
process.once = noop;
process.off = noop;
process.removeListener = noop;
process.removeAllListeners = noop;
process.emit = noop;
process.prependListener = noop;
process.prependOnceListener = noop;
process.listeners = function (name) { return [] }
process.binding = function (name) {
throw new Error('process.binding is not supported');
};
process.cwd = function () { return '/' };
process.chdir = function (dir) {
throw new Error('process.chdir is not supported');
};
process.umask = function() { return 0; };

View File

@ -1,2 +0,0 @@
// for now just expose the builtin process global from node.js
module.exports = global.process;

View File

@ -1,27 +0,0 @@
{
"author": "Roman Shtylman <shtylman@gmail.com>",
"name": "process",
"description": "process information for node.js and browsers",
"keywords": [
"process"
],
"scripts": {
"test": "mocha test.js",
"browser": "zuul --no-coverage --ui mocha-bdd --local 8080 -- test.js"
},
"version": "0.11.10",
"repository": {
"type": "git",
"url": "git://github.com/shtylman/node-process.git"
},
"license": "MIT",
"browser": "./browser.js",
"main": "./index.js",
"engines": {
"node": ">= 0.6.0"
},
"devDependencies": {
"mocha": "2.2.1",
"zuul": "^3.10.3"
}
}

View File

@ -1,199 +0,0 @@
var assert = require('assert');
var ourProcess = require('./browser');
describe('test against our process', function () {
test(ourProcess);
});
if (!process.browser) {
describe('test against node', function () {
test(process);
});
vmtest();
}
function test (ourProcess) {
describe('test arguments', function () {
it ('works', function (done) {
var order = 0;
ourProcess.nextTick(function (num) {
assert.equal(num, order++, 'first one works');
ourProcess.nextTick(function (num) {
assert.equal(num, order++, 'recursive one is 4th');
}, 3);
}, 0);
ourProcess.nextTick(function (num) {
assert.equal(num, order++, 'second one starts');
ourProcess.nextTick(function (num) {
assert.equal(num, order++, 'this is third');
ourProcess.nextTick(function (num) {
assert.equal(num, order++, 'this is last');
done();
}, 5);
}, 4);
}, 1);
ourProcess.nextTick(function (num) {
assert.equal(num, order++, '3rd schedualed happens after the error');
}, 2);
});
});
if (!process.browser) {
describe('test errors', function (t) {
it ('works', function (done) {
var order = 0;
process.removeAllListeners('uncaughtException');
process.once('uncaughtException', function(err) {
assert.equal(2, order++, 'error is third');
ourProcess.nextTick(function () {
assert.equal(5, order++, 'schedualed in error is last');
done();
});
});
ourProcess.nextTick(function () {
assert.equal(0, order++, 'first one works');
ourProcess.nextTick(function () {
assert.equal(4, order++, 'recursive one is 4th');
});
});
ourProcess.nextTick(function () {
assert.equal(1, order++, 'second one starts');
throw(new Error('an error is thrown'));
});
ourProcess.nextTick(function () {
assert.equal(3, order++, '3rd schedualed happens after the error');
});
});
});
}
describe('rename globals', function (t) {
var oldTimeout = setTimeout;
var oldClear = clearTimeout;
it('clearTimeout', function (done){
var ok = true;
clearTimeout = function () {
ok = false;
}
var ran = false;
function cleanup() {
clearTimeout = oldClear;
var err;
try {
assert.ok(ok, 'fake clearTimeout ran');
assert.ok(ran, 'should have run');
} catch (e) {
err = e;
}
done(err);
}
setTimeout(cleanup, 1000);
ourProcess.nextTick(function () {
ran = true;
});
});
it('just setTimeout', function (done){
setTimeout = function () {
setTimeout = oldTimeout;
try {
assert.ok(false, 'fake setTimeout called')
} catch (e) {
done(e);
}
}
ourProcess.nextTick(function () {
setTimeout = oldTimeout;
done();
});
});
});
}
function vmtest() {
var vm = require('vm');
var fs = require('fs');
var process = fs.readFileSync('./browser.js', {encoding: 'utf8'});
describe('should work in vm in strict mode with no globals', function () {
it('should parse', function (done) {
var str = '"use strict";var module = {exports:{}};';
str += process;
str += 'this.works = process.browser;';
var script = new vm.Script(str);
var context = {
works: false
};
script.runInNewContext(context);
assert.ok(context.works);
done();
});
it('setTimeout throws error', function (done) {
var str = '"use strict";var module = {exports:{}};';
str += process;
str += 'try {process.nextTick(function () {})} catch (e){this.works = e;}';
var script = new vm.Script(str);
var context = {
works: false
};
script.runInNewContext(context);
assert.ok(context.works);
done();
});
it('should generally work', function (done) {
var str = '"use strict";var module = {exports:{}};';
str += process;
str += 'process.nextTick(function () {assert.ok(true);done();})';
var script = new vm.Script(str);
var context = {
clearTimeout: clearTimeout,
setTimeout: setTimeout,
done: done,
assert: assert
};
script.runInNewContext(context);
});
it('late defs setTimeout', function (done) {
var str = '"use strict";var module = {exports:{}};';
str += process;
str += 'var setTimeout = hiddenSetTimeout;process.nextTick(function () {assert.ok(true);done();})';
var script = new vm.Script(str);
var context = {
clearTimeout: clearTimeout,
hiddenSetTimeout: setTimeout,
done: done,
assert: assert
};
script.runInNewContext(context);
});
it('late defs clearTimeout', function (done) {
var str = '"use strict";var module = {exports:{}};';
str += process;
str += 'var clearTimeout = hiddenClearTimeout;process.nextTick(function () {assert.ok(true);done();})';
var script = new vm.Script(str);
var context = {
hiddenClearTimeout: clearTimeout,
setTimeout: setTimeout,
done: done,
assert: assert
};
script.runInNewContext(context);
});
it('late defs setTimeout and then redefine', function (done) {
var str = '"use strict";var module = {exports:{}};';
str += process;
str += 'var setTimeout = hiddenSetTimeout;process.nextTick(function () {setTimeout = function (){throw new Error("foo")};hiddenSetTimeout(function(){process.nextTick(function (){assert.ok(true);done();});});});';
var script = new vm.Script(str);
var context = {
clearTimeout: clearTimeout,
hiddenSetTimeout: setTimeout,
done: done,
assert: assert
};
script.runInNewContext(context);
});
});
}

View File

@ -1,18 +0,0 @@
{
"node": true,
"browser": true,
"browserify": true,
"curly": true,
"eqeqeq": true,
"eqnull": false,
"latedef": "nofunc",
"newcap": true,
"noarg": true,
"undef": true,
"strict": true,
"trailing": true,
"smarttabs": true,
"indent": 2,
"quotmark": true,
"laxbreak": true
}

View File

@ -1,7 +0,0 @@
language: node_js
sudo: false
node_js:
- "4.1"
- "4.0"
- "0.12"
- "0.10"

View File

@ -1,116 +0,0 @@
2.3.0 - July 13 2015
====================
* Correctly handle quoted keys ([#21](https://github.com/BinaryMuse/toml-node/issues/21))
2.2.3 - June 8 2015
===================
* Support empty inline tables ([#24](https://github.com/BinaryMuse/toml-node/issues/24))
* Do not allow implicit table definitions to replace value ([#23](https://github.com/BinaryMuse/toml-node/issues/23))
* Don't allow tables to replace inline tables ([#25](https://github.com/BinaryMuse/toml-node/issues/25))
2.2.2 - April 3 2015
====================
* Correctly handle newlines at beginning of string ([#22](https://github.com/BinaryMuse/toml-node/issues/22))
2.2.1 - March 17 2015
=====================
* Parse dates generated by Date#toISOString() ([#20](https://github.com/BinaryMuse/toml-node/issues/20))
2.2.0 - Feb 26 2015
===================
* Support TOML spec v0.4.0
2.1.0 - Jan 7 2015
==================
* Support TOML spec v0.3.1
2.0.6 - May 23 2014
===================
### Bug Fixes
* Fix support for empty arrays with newlines ([#13](https://github.com/BinaryMuse/toml-node/issues/13))
2.0.5 - May 5 2014
==================
### Bug Fixes
* Fix loop iteration leak, by [sebmck](https://github.com/sebmck) ([#12](https://github.com/BinaryMuse/toml-node/pull/12))
### Development
* Tests now run JSHint on `lib/compiler.js`
2.0.4 - Mar 9 2014
==================
### Bug Fixes
* Fix failure on duplicate table name inside table array ([#11](https://github.com/BinaryMuse/toml-node/issues/11))
2.0.2 - Feb 23 2014
===================
### Bug Fixes
* Fix absence of errors when table path starts or ends with period
2.0.1 - Feb 23 2014
===================
### Bug Fixes
* Fix incorrect messaging in array type errors
* Fix missing error when overwriting key with table array
2.0.0 - Feb 23 2014
===================
### Features
* Add support for [version 0.2 of the TOML spec](https://github.com/mojombo/toml/blob/master/versions/toml-v0.2.0.md) ([#9](https://github.com/BinaryMuse/toml-node/issues/9))
### Internals
* Upgrade to PEG.js v0.8 and rewrite compiler; parser is now considerably faster (from ~7000ms to ~1000ms to parse `example.toml` 1000 times on Node.js v0.10)
1.0.4 - Aug 17 2013
===================
### Bug Fixes
* Fix support for empty arrays
1.0.3 - Aug 17 2013
===================
### Bug Fixes
* Fix typo in array type error message
* Fix single-element arrays with no trailing commas
1.0.2 - Aug 17 2013
===================
### Bug Fixes
* Fix errors on lines that contain only whitespace ([#7](https://github.com/BinaryMuse/toml-node/issues/7))
1.0.1 - Aug 17 2013
===================
### Internals
* Remove old code remaining from the remove streaming API
1.0.0 - Aug 17 2013
===================
Initial stable release

View File

@ -1,22 +0,0 @@
Copyright (c) 2012 Michelle Tilley
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.

View File

@ -1,93 +0,0 @@
TOML Parser for Node.js
=======================
[![Build Status](https://travis-ci.org/BinaryMuse/toml-node.png?branch=master)](https://travis-ci.org/BinaryMuse/toml-node)
[![NPM](https://nodei.co/npm/toml.png?downloads=true)](https://nodei.co/npm/toml/)
If you haven't heard of TOML, well you're just missing out. [Go check it out now.](https://github.com/mojombo/toml) Back? Good.
TOML Spec Support
-----------------
toml-node supports version 0.4.0 the TOML spec as specified by [mojombo/toml@v0.4.0](https://github.com/mojombo/toml/blob/master/versions/en/toml-v0.4.0.md)
Installation
------------
toml-node is available via npm.
npm install toml
toml-node also works with browser module bundlers like Browserify and webpack.
Usage
-----
### Standalone
Say you have some awesome TOML in a variable called `someTomlString`. Maybe it came from the web; maybe it came from a file; wherever it came from, it came asynchronously! Let's turn that sucker into a JavaScript object.
```javascript
var toml = require('toml');
var data = toml.parse(someTomlString);
console.dir(data);
```
`toml.parse` throws an exception in the case of a parsing error; such exceptions have a `line` and `column` property on them to help identify the offending text.
```javascript
try {
toml.parse(someCrazyKnuckleHeadedTrblToml);
} catch (e) {
console.error("Parsing error on line " + e.line + ", column " + e.column +
": " + e.message);
}
```
### Streaming
As of toml-node version 1.0, the streaming interface has been removed. Instead, use a module like [concat-stream](https://npmjs.org/package/concat-stream):
```javascript
var toml = require('toml');
var concat = require('concat-stream');
var fs = require('fs');
fs.createReadStream('tomlFile.toml', 'utf8').pipe(concat(function(data) {
var parsed = toml.parse(data);
}));
```
Thanks [@ForbesLindesay](https://github.com/ForbesLindesay) for the suggestion.
### Requiring with Node.js
You can use the [toml-require package](https://github.com/BinaryMuse/toml-require) to `require()` your `.toml` files with Node.js
Live Demo
---------
You can experiment with TOML online at http://binarymuse.github.io/toml-node/, which uses the latest version of this library.
Building & Testing
------------------
toml-node uses [the PEG.js parser generator](http://pegjs.majda.cz/).
npm install
npm run build
npm test
Any changes to `src/toml.peg` requires a regeneration of the parser with `npm run build`.
toml-node is tested on Travis CI and is tested against:
* Node 0.10
* Node 0.12
* Latest stable io.js
License
-------
toml-node is licensed under the MIT license agreement. See the LICENSE file for more information.

View File

@ -1,12 +0,0 @@
var toml = require('./index');
var fs = require('fs');
var data = fs.readFileSync('./test/example.toml', 'utf8');
var iterations = 1000;
var start = new Date();
for(var i = 0; i < iterations; i++) {
toml.parse(data);
}
var end = new Date();
console.log("%s iterations in %sms", iterations, end - start);

View File

@ -1,9 +0,0 @@
var parser = require('./lib/parser');
var compiler = require('./lib/compiler');
module.exports = {
parse: function(input) {
var nodes = parser.parse(input.toString());
return compiler.compile(nodes);
}
};

View File

@ -1,195 +0,0 @@
"use strict";
function compile(nodes) {
var assignedPaths = [];
var valueAssignments = [];
var currentPath = "";
var data = Object.create(null);
var context = data;
var arrayMode = false;
return reduce(nodes);
function reduce(nodes) {
var node;
for (var i = 0; i < nodes.length; i++) {
node = nodes[i];
switch (node.type) {
case "Assign":
assign(node);
break;
case "ObjectPath":
setPath(node);
break;
case "ArrayPath":
addTableArray(node);
break;
}
}
return data;
}
function genError(err, line, col) {
var ex = new Error(err);
ex.line = line;
ex.column = col;
throw ex;
}
function assign(node) {
var key = node.key;
var value = node.value;
var line = node.line;
var column = node.column;
var fullPath;
if (currentPath) {
fullPath = currentPath + "." + key;
} else {
fullPath = key;
}
if (typeof context[key] !== "undefined") {
genError("Cannot redefine existing key '" + fullPath + "'.", line, column);
}
context[key] = reduceValueNode(value);
if (!pathAssigned(fullPath)) {
assignedPaths.push(fullPath);
valueAssignments.push(fullPath);
}
}
function pathAssigned(path) {
return assignedPaths.indexOf(path) !== -1;
}
function reduceValueNode(node) {
if (node.type === "Array") {
return reduceArrayWithTypeChecking(node.value);
} else if (node.type === "InlineTable") {
return reduceInlineTableNode(node.value);
} else {
return node.value;
}
}
function reduceInlineTableNode(values) {
var obj = Object.create(null);
for (var i = 0; i < values.length; i++) {
var val = values[i];
if (val.value.type === "InlineTable") {
obj[val.key] = reduceInlineTableNode(val.value.value);
} else if (val.type === "InlineTableValue") {
obj[val.key] = reduceValueNode(val.value);
}
}
return obj;
}
function setPath(node) {
var path = node.value;
var quotedPath = path.map(quoteDottedString).join(".");
var line = node.line;
var column = node.column;
if (pathAssigned(quotedPath)) {
genError("Cannot redefine existing key '" + path + "'.", line, column);
}
assignedPaths.push(quotedPath);
context = deepRef(data, path, Object.create(null), line, column);
currentPath = path;
}
function addTableArray(node) {
var path = node.value;
var quotedPath = path.map(quoteDottedString).join(".");
var line = node.line;
var column = node.column;
if (!pathAssigned(quotedPath)) {
assignedPaths.push(quotedPath);
}
assignedPaths = assignedPaths.filter(function(p) {
return p.indexOf(quotedPath) !== 0;
});
assignedPaths.push(quotedPath);
context = deepRef(data, path, [], line, column);
currentPath = quotedPath;
if (context instanceof Array) {
var newObj = Object.create(null);
context.push(newObj);
context = newObj;
} else {
genError("Cannot redefine existing key '" + path + "'.", line, column);
}
}
// Given a path 'a.b.c', create (as necessary) `start.a`,
// `start.a.b`, and `start.a.b.c`, assigning `value` to `start.a.b.c`.
// If `a` or `b` are arrays and have items in them, the last item in the
// array is used as the context for the next sub-path.
function deepRef(start, keys, value, line, column) {
var traversed = [];
var traversedPath = "";
var path = keys.join(".");
var ctx = start;
for (var i = 0; i < keys.length; i++) {
var key = keys[i];
traversed.push(key);
traversedPath = traversed.join(".");
if (typeof ctx[key] === "undefined") {
if (i === keys.length - 1) {
ctx[key] = value;
} else {
ctx[key] = Object.create(null);
}
} else if (i !== keys.length - 1 && valueAssignments.indexOf(traversedPath) > -1) {
// already a non-object value at key, can't be used as part of a new path
genError("Cannot redefine existing key '" + traversedPath + "'.", line, column);
}
ctx = ctx[key];
if (ctx instanceof Array && ctx.length && i < keys.length - 1) {
ctx = ctx[ctx.length - 1];
}
}
return ctx;
}
function reduceArrayWithTypeChecking(array) {
// Ensure that all items in the array are of the same type
var firstType = null;
for (var i = 0; i < array.length; i++) {
var node = array[i];
if (firstType === null) {
firstType = node.type;
} else {
if (node.type !== firstType) {
genError("Cannot add value of type " + node.type + " to array of type " +
firstType + ".", node.line, node.column);
}
}
}
// Recursively reduce array of nodes into array of the nodes' values
return array.map(reduceValueNode);
}
function quoteDottedString(str) {
if (str.indexOf(".") > -1) {
return "\"" + str + "\"";
} else {
return str;
}
}
}
module.exports = {
compile: compile
};

File diff suppressed because it is too large Load Diff

View File

@ -1,24 +0,0 @@
{
"name": "toml",
"version": "3.0.0",
"description": "TOML parser for Node.js (parses TOML spec v0.4.0)",
"main": "index.js",
"types": "index.d.ts",
"scripts": {
"build": "pegjs --cache src/toml.pegjs lib/parser.js",
"test": "jshint lib/compiler.js && nodeunit test/test_*.js",
"prepublish": "npm run build"
},
"repository": "git://github.com/BinaryMuse/toml-node.git",
"keywords": [
"toml",
"parser"
],
"author": "Michelle Tilley <michelle@michelletilley.net>",
"license": "MIT",
"devDependencies": {
"jshint": "*",
"nodeunit": "~0.9.0",
"pegjs": "~0.8.0"
}
}

View File

@ -1,231 +0,0 @@
{
var nodes = [];
function genError(err, line, col) {
var ex = new Error(err);
ex.line = line;
ex.column = col;
throw ex;
}
function addNode(node) {
nodes.push(node);
}
function node(type, value, line, column, key) {
var obj = { type: type, value: value, line: line(), column: column() };
if (key) obj.key = key;
return obj;
}
function convertCodePoint(str, line, col) {
var num = parseInt("0x" + str);
if (
!isFinite(num) ||
Math.floor(num) != num ||
num < 0 ||
num > 0x10FFFF ||
(num > 0xD7FF && num < 0xE000)
) {
genError("Invalid Unicode escape code: " + str, line, col);
} else {
return fromCodePoint(num);
}
}
function fromCodePoint() {
var MAX_SIZE = 0x4000;
var codeUnits = [];
var highSurrogate;
var lowSurrogate;
var index = -1;
var length = arguments.length;
if (!length) {
return '';
}
var result = '';
while (++index < length) {
var codePoint = Number(arguments[index]);
if (codePoint <= 0xFFFF) { // BMP code point
codeUnits.push(codePoint);
} else { // Astral code point; split in surrogate halves
// http://mathiasbynens.be/notes/javascript-encoding#surrogate-formulae
codePoint -= 0x10000;
highSurrogate = (codePoint >> 10) + 0xD800;
lowSurrogate = (codePoint % 0x400) + 0xDC00;
codeUnits.push(highSurrogate, lowSurrogate);
}
if (index + 1 == length || codeUnits.length > MAX_SIZE) {
result += String.fromCharCode.apply(null, codeUnits);
codeUnits.length = 0;
}
}
return result;
}
}
start
= line* { return nodes }
line
= S* expr:expression S* comment* (NL+ / EOF)
/ S+ (NL+ / EOF)
/ NL
expression
= comment / path / tablearray / assignment
comment
= '#' (!(NL / EOF) .)*
path
= '[' S* name:table_key S* ']' { addNode(node('ObjectPath', name, line, column)) }
tablearray
= '[' '[' S* name:table_key S* ']' ']' { addNode(node('ArrayPath', name, line, column)) }
table_key
= parts:dot_ended_table_key_part+ name:table_key_part { return parts.concat(name) }
/ name:table_key_part { return [name] }
table_key_part
= S* name:key S* { return name }
/ S* name:quoted_key S* { return name }
dot_ended_table_key_part
= S* name:key S* '.' S* { return name }
/ S* name:quoted_key S* '.' S* { return name }
assignment
= key:key S* '=' S* value:value { addNode(node('Assign', value, line, column, key)) }
/ key:quoted_key S* '=' S* value:value { addNode(node('Assign', value, line, column, key)) }
key
= chars:ASCII_BASIC+ { return chars.join('') }
quoted_key
= node:double_quoted_single_line_string { return node.value }
/ node:single_quoted_single_line_string { return node.value }
value
= string / datetime / float / integer / boolean / array / inline_table
string
= double_quoted_multiline_string
/ double_quoted_single_line_string
/ single_quoted_multiline_string
/ single_quoted_single_line_string
double_quoted_multiline_string
= '"""' NL? chars:multiline_string_char* '"""' { return node('String', chars.join(''), line, column) }
double_quoted_single_line_string
= '"' chars:string_char* '"' { return node('String', chars.join(''), line, column) }
single_quoted_multiline_string
= "'''" NL? chars:multiline_literal_char* "'''" { return node('String', chars.join(''), line, column) }
single_quoted_single_line_string
= "'" chars:literal_char* "'" { return node('String', chars.join(''), line, column) }
string_char
= ESCAPED / (!'"' char:. { return char })
literal_char
= (!"'" char:. { return char })
multiline_string_char
= ESCAPED / multiline_string_delim / (!'"""' char:. { return char})
multiline_string_delim
= '\\' NL NLS* { return '' }
multiline_literal_char
= (!"'''" char:. { return char })
float
= left:(float_text / integer_text) ('e' / 'E') right:integer_text { return node('Float', parseFloat(left + 'e' + right), line, column) }
/ text:float_text { return node('Float', parseFloat(text), line, column) }
float_text
= '+'? digits:(DIGITS '.' DIGITS) { return digits.join('') }
/ '-' digits:(DIGITS '.' DIGITS) { return '-' + digits.join('') }
integer
= text:integer_text { return node('Integer', parseInt(text, 10), line, column) }
integer_text
= '+'? digits:DIGIT+ !'.' { return digits.join('') }
/ '-' digits:DIGIT+ !'.' { return '-' + digits.join('') }
boolean
= 'true' { return node('Boolean', true, line, column) }
/ 'false' { return node('Boolean', false, line, column) }
array
= '[' array_sep* ']' { return node('Array', [], line, column) }
/ '[' value:array_value? ']' { return node('Array', value ? [value] : [], line, column) }
/ '[' values:array_value_list+ ']' { return node('Array', values, line, column) }
/ '[' values:array_value_list+ value:array_value ']' { return node('Array', values.concat(value), line, column) }
array_value
= array_sep* value:value array_sep* { return value }
array_value_list
= array_sep* value:value array_sep* ',' array_sep* { return value }
array_sep
= S / NL / comment
inline_table
= '{' S* values:inline_table_assignment* S* '}' { return node('InlineTable', values, line, column) }
inline_table_assignment
= S* key:key S* '=' S* value:value S* ',' S* { return node('InlineTableValue', value, line, column, key) }
/ S* key:key S* '=' S* value:value { return node('InlineTableValue', value, line, column, key) }
secfragment
= '.' digits:DIGITS { return "." + digits }
date
= date:(
DIGIT DIGIT DIGIT DIGIT
'-'
DIGIT DIGIT
'-'
DIGIT DIGIT
) { return date.join('') }
time
= time:(DIGIT DIGIT ':' DIGIT DIGIT ':' DIGIT DIGIT secfragment?) { return time.join('') }
time_with_offset
= time:(
DIGIT DIGIT ':' DIGIT DIGIT ':' DIGIT DIGIT secfragment?
('-' / '+')
DIGIT DIGIT ':' DIGIT DIGIT
) { return time.join('') }
datetime
= date:date 'T' time:time 'Z' { return node('Date', new Date(date + "T" + time + "Z"), line, column) }
/ date:date 'T' time:time_with_offset { return node('Date', new Date(date + "T" + time), line, column) }
S = [ \t]
NL = "\n" / "\r" "\n"
NLS = NL / S
EOF = !.
HEX = [0-9a-f]i
DIGIT = DIGIT_OR_UNDER
DIGIT_OR_UNDER = [0-9]
/ '_' { return "" }
ASCII_BASIC = [A-Za-z0-9_\-]
DIGITS = d:DIGIT_OR_UNDER+ { return d.join('') }
ESCAPED = '\\"' { return '"' }
/ '\\\\' { return '\\' }
/ '\\b' { return '\b' }
/ '\\t' { return '\t' }
/ '\\n' { return '\n' }
/ '\\f' { return '\f' }
/ '\\r' { return '\r' }
/ ESCAPED_UNICODE
ESCAPED_UNICODE = "\\U" digits:(HEX HEX HEX HEX HEX HEX HEX HEX) { return convertCodePoint(digits.join('')) }
/ "\\u" digits:(HEX HEX HEX HEX) { return convertCodePoint(digits.join('')) }

View File

@ -1,5 +0,0 @@
[something]
awesome = "this is"
[something.awesome]
this = "isn't"

View File

@ -1,32 +0,0 @@
# This is a TOML document. Boom.
title = "TOML Example"
[owner]
name = "Tom Preston-Werner"
organization = "GitHub"
bio = "GitHub Cofounder & CEO\n\tLikes \"tater tots\" and beer and backslashes: \\"
dob = 1979-05-27T07:32:00Z # First class dates? Why not?
[database]
server = "192.168.1.1"
ports = [ 8001, 8001, 8003 ]
connection_max = 5000
connection_min = -2 # Don't ask me how
max_temp = 87.1 # It's a float
min_temp = -17.76
enabled = true
[servers]
# You can indent as you please. Tabs or spaces. TOML don't care.
[servers.alpha]
ip = "10.0.0.1"
dc = "eqdc10"
[servers.beta]
ip = "10.0.0.2"
dc = "eqdc10"
[clients]
data = [ ["gamma", "delta"], [1, 2] ] # just an update to make sure parsers support it

View File

@ -1,33 +0,0 @@
# Test file for TOML
# Only this one tries to emulate a TOML file written by a user of the kind of parser writers probably hate
# This part you'll really hate
[the]
test_string = "You'll hate me after this - #" # " Annoying, isn't it?
[the.hard]
test_array = [ "] ", " # "] # ] There you go, parse this!
test_array2 = [ "Test #11 ]proved that", "Experiment #9 was a success" ]
# You didn't think it'd as easy as chucking out the last #, did you?
another_test_string = " Same thing, but with a string #"
harder_test_string = " And when \"'s are in the string, along with # \"" # "and comments are there too"
# Things will get harder
[the.hard."bit#"]
"what?" = "You don't think some user won't do that?"
multi_line_array = [
"]",
# ] Oh yes I did
]
# Each of the following keygroups/key value pairs should produce an error. Uncomment to them to test
#[error] if you didn't catch this, your parser is broken
#string = "Anything other than tabs, spaces and newline after a keygroup or key value pair has ended should produce an error unless it is a comment" like this
#array = [
# "This might most likely happen in multiline arrays",
# Like here,
# "or here,
# and here"
# ] End of array comment, forgot the #
#number = 3.14 pi <--again forgot the #

View File

@ -1,10 +0,0 @@
name = { first = "Tom", last = "Preston-Werner" }
point = { x = 1, y = 2 }
nested = { x = { a = { b = 3 } } }
points = [ { x = 1, y = 2, z = 3 },
{ x = 7, y = 8, z = 9 },
{ x = 2, y = 4, z = 8 } ]
arrays = [ { x = [1, 2, 3], y = [4, 5, 6] },
{ x = [7, 8, 9], y = [0, 1, 2] } ]

View File

@ -1,5 +0,0 @@
# What you see is what you get.
winpath = 'C:\Users\nodejs\templates'
winpath2 = '\\ServerX\admin$\system32\'
quoted = 'Tom "Dubs" Preston-Werner'
regex = '<\i\c*\s*>'

View File

@ -1,15 +0,0 @@
# The following strings are byte-for-byte equivalent:
key1 = "The quick brown fox jumps over the lazy dog."
key2 = """
The quick brown \
fox jumps over \
the lazy dog."""
key3 = """\
The quick brown \
fox jumps over \
the lazy dog.\
"""

View File

@ -1,7 +0,0 @@
regex2 = '''I [dw]on't need \d{2} apples'''
lines = '''
The first newline is
trimmed in raw strings.
All other whitespace
is preserved.
'''

View File

@ -1,6 +0,0 @@
# The following strings are byte-for-byte equivalent:
key1 = "One\nTwo"
key2 = """One\nTwo"""
key3 = """
One
Two"""

View File

@ -1,22 +0,0 @@
var fs = require('fs');
var parser = require('../index');
var codes = [
"# test\n my.key=\"value\"\nother = 101\nthird = -37",
"first = 1.2\nsecond = -56.02\nth = true\nfth = false",
"time = 1979-05-27T07:32:00Z",
"test = [\"one\", ]",
"test = [[1, 2,], [true, false,],]",
"[my.sub.path]\nkey = true\nother = -15.3\n[my.sub]\nkey=false",
"arry = [\"one\", \"two\",\"thr\nee\", \"\\u03EA\"]",
fs.readFileSync(__dirname + '/example.toml', 'utf8'),
fs.readFileSync(__dirname + '/hard_example.toml', 'utf8')
]
console.log("=============================================");
for(i in codes) {
var code = codes[i];
console.log(code + "\n");
console.log(JSON.stringify(parser.parse(code)));
console.log("=============================================");
}

View File

@ -1,10 +0,0 @@
[[products]]
name = "Hammer"
sku = 738594937
[[products]]
[[products]]
name = "Nail"
sku = 284758393
color = "gray"

View File

@ -1,31 +0,0 @@
[[fruit]]
name = "durian"
variety = []
[[fruit]]
name = "apple"
[fruit.physical]
color = "red"
shape = "round"
[[fruit.variety]]
name = "red delicious"
[[fruit.variety]]
name = "granny smith"
[[fruit]]
[[fruit]]
name = "banana"
[[fruit.variety]]
name = "plantain"
[[fruit]]
name = "orange"
[fruit.physical]
color = "orange"
shape = "round"

View File

@ -1,596 +0,0 @@
var toml = require('../');
var fs = require('fs');
var assert = require("nodeunit").assert;
assert.parsesToml = function(tomlStr, expected) {
try {
var actual = toml.parse(tomlStr);
} catch (e) {
var errInfo = "line: " + e.line + ", column: " + e.column;
return assert.fail("TOML parse error: " + e.message, errInfo, null, "at", assert.parsesToml);
}
return assert.deepEqual(actual, expected);
};
var exampleExpected = {
title: "TOML Example",
owner: {
name: "Tom Preston-Werner",
organization: "GitHub",
bio: "GitHub Cofounder & CEO\n\tLikes \"tater tots\" and beer and backslashes: \\",
dob: new Date("1979-05-27T07:32:00Z")
},
database: {
server: "192.168.1.1",
ports: [8001, 8001, 8003],
connection_max: 5000,
connection_min: -2,
max_temp: 87.1,
min_temp: -17.76,
enabled: true
},
servers: {
alpha: {
ip: "10.0.0.1",
dc: "eqdc10"
},
beta: {
ip: "10.0.0.2",
dc: "eqdc10"
}
},
clients: {
data: [ ["gamma", "delta"], [1, 2] ]
}
};
var hardExampleExpected = {
the: {
hard: {
another_test_string: ' Same thing, but with a string #',
'bit#': {
multi_line_array: [']'],
'what?': "You don't think some user won't do that?"
},
harder_test_string: " And when \"'s are in the string, along with # \"",
test_array: ['] ', ' # '],
test_array2: ['Test #11 ]proved that', 'Experiment #9 was a success']
},
test_string: "You'll hate me after this - #"
}
};
var easyTableArrayExpected = {
"products": [
{ "name": "Hammer", "sku": 738594937 },
{ },
{ "name": "Nail", "sku": 284758393, "color": "gray" }
]
};
var hardTableArrayExpected = {
"fruit": [
{
"name": "durian",
"variety": []
},
{
"name": "apple",
"physical": {
"color": "red",
"shape": "round"
},
"variety": [
{ "name": "red delicious" },
{ "name": "granny smith" }
]
},
{},
{
"name": "banana",
"variety": [
{ "name": "plantain" }
]
},
{
"name": "orange",
"physical": {
"color": "orange",
"shape": "round"
}
}
]
}
var badInputs = [
'[error] if you didn\'t catch this, your parser is broken',
'string = "Anything other than tabs, spaces and newline after a table or key value pair has ended should produce an error unless it is a comment" like this',
'array = [\n \"This might most likely happen in multiline arrays\",\n Like here,\n \"or here,\n and here\"\n ] End of array comment, forgot the #',
'number = 3.14 pi <--again forgot the #'
];
exports.testParsesExample = function(test) {
var str = fs.readFileSync(__dirname + "/example.toml", 'utf-8')
test.parsesToml(str, exampleExpected);
test.done();
};
exports.testParsesHardExample = function(test) {
var str = fs.readFileSync(__dirname + "/hard_example.toml", 'utf-8')
test.parsesToml(str, hardExampleExpected);
test.done();
};
exports.testEasyTableArrays = function(test) {
var str = fs.readFileSync(__dirname + "/table_arrays_easy.toml", 'utf8')
test.parsesToml(str, easyTableArrayExpected);
test.done();
};
exports.testHarderTableArrays = function(test) {
var str = fs.readFileSync(__dirname + "/table_arrays_hard.toml", 'utf8')
test.parsesToml(str, hardTableArrayExpected);
test.done();
};
exports.testSupportsTrailingCommasInArrays = function(test) {
var str = 'arr = [1, 2, 3,]';
var expected = { arr: [1, 2, 3] };
test.parsesToml(str, expected);
test.done();
};
exports.testSingleElementArrayWithNoTrailingComma = function(test) {
var str = "a = [1]";
test.parsesToml(str, {
a: [1]
});
test.done();
};
exports.testEmptyArray = function(test) {
var str = "a = []";
test.parsesToml(str, {
a: []
});
test.done();
};
exports.testArrayWithWhitespace = function(test) {
var str = "[versions]\nfiles = [\n 3, \n 5 \n\n ]";
test.parsesToml(str, {
versions: {
files: [3, 5]
}
});
test.done();
};
exports.testEmptyArrayWithWhitespace = function(test) {
var str = "[versions]\nfiles = [\n \n ]";
test.parsesToml(str, {
versions: {
files: []
}
});
test.done();
};
exports.testDefineOnSuperkey = function(test) {
var str = "[a.b]\nc = 1\n\n[a]\nd = 2";
var expected = {
a: {
b: {
c: 1
},
d: 2
}
};
test.parsesToml(str, expected);
test.done();
};
exports.testWhitespace = function(test) {
var str = "a = 1\n \n b = 2 ";
test.parsesToml(str, {
a: 1, b: 2
});
test.done();
};
exports.testUnicode = function(test) {
var str = "str = \"My name is Jos\\u00E9\"";
test.parsesToml(str, {
str: "My name is Jos\u00E9"
});
var str = "str = \"My name is Jos\\U000000E9\"";
test.parsesToml(str, {
str: "My name is Jos\u00E9"
});
test.done();
};
exports.testMultilineStrings = function(test) {
var str = fs.readFileSync(__dirname + "/multiline_strings.toml", 'utf8');
test.parsesToml(str, {
key1: "One\nTwo",
key2: "One\nTwo",
key3: "One\nTwo"
});
test.done();
};
exports.testMultilineEatWhitespace = function(test) {
var str = fs.readFileSync(__dirname + "/multiline_eat_whitespace.toml", 'utf8');
test.parsesToml(str, {
key1: "The quick brown fox jumps over the lazy dog.",
key2: "The quick brown fox jumps over the lazy dog.",
key3: "The quick brown fox jumps over the lazy dog."
});
test.done();
};
exports.testLiteralStrings = function(test) {
var str = fs.readFileSync(__dirname + "/literal_strings.toml", 'utf8');
test.parsesToml(str, {
winpath: "C:\\Users\\nodejs\\templates",
winpath2: "\\\\ServerX\\admin$\\system32\\",
quoted: "Tom \"Dubs\" Preston-Werner",
regex: "<\\i\\c*\\s*>"
});
test.done();
};
exports.testMultilineLiteralStrings = function(test) {
var str = fs.readFileSync(__dirname + "/multiline_literal_strings.toml", 'utf8');
test.parsesToml(str, {
regex2: "I [dw]on't need \\d{2} apples",
lines: "The first newline is\ntrimmed in raw strings.\n All other whitespace\n is preserved.\n"
});
test.done();
};
exports.testIntegerFormats = function(test) {
var str = "a = +99\nb = 42\nc = 0\nd = -17\ne = 1_000_001\nf = 1_2_3_4_5 # why u do dis";
test.parsesToml(str, {
a: 99,
b: 42,
c: 0,
d: -17,
e: 1000001,
f: 12345
});
test.done();
};
exports.testFloatFormats = function(test) {
var str = "a = +1.0\nb = 3.1415\nc = -0.01\n" +
"d = 5e+22\ne = 1e6\nf = -2E-2\n" +
"g = 6.626e-34\n" +
"h = 9_224_617.445_991_228_313\n" +
"i = 1e1_000";
test.parsesToml(str, {
a: 1.0,
b: 3.1415,
c: -0.01,
d: 5e22,
e: 1e6,
f: -2e-2,
g: 6.626e-34,
h: 9224617.445991228313,
i: 1e1000
});
test.done();
};
exports.testDate = function(test) {
var date = new Date("1979-05-27T07:32:00Z");
test.parsesToml("a = 1979-05-27T07:32:00Z", {
a: date
});
test.done();
};
exports.testDateWithOffset = function(test) {
var date1 = new Date("1979-05-27T07:32:00-07:00"),
date2 = new Date("1979-05-27T07:32:00+02:00");
test.parsesToml("a = 1979-05-27T07:32:00-07:00\nb = 1979-05-27T07:32:00+02:00", {
a: date1,
b: date2
});
test.done();
};
exports.testDateWithSecondFraction = function(test) {
var date = new Date("1979-05-27T00:32:00.999999-07:00");
test.parsesToml("a = 1979-05-27T00:32:00.999999-07:00", {
a: date
});
test.done();
};
exports.testDateFromIsoString = function(test) {
// https://github.com/BinaryMuse/toml-node/issues/20
var date = new Date(),
dateStr = date.toISOString(),
tomlStr = "a = " + dateStr;
test.parsesToml(tomlStr, {
a: date
});
test.done();
};
exports.testLeadingNewlines = function(test) {
// https://github.com/BinaryMuse/toml-node/issues/22
var str = "\ntest = \"ing\"";
test.parsesToml(str, {
test: "ing"
});
test.done();
};
exports.testInlineTables = function(test) {
var str = fs.readFileSync(__dirname + "/inline_tables.toml", 'utf8');
test.parsesToml(str, {
name: {
first: "Tom",
last: "Preston-Werner"
},
point: {
x: 1,
y: 2
},
nested: {
x: {
a: {
b: 3
}
}
},
points: [
{ x: 1, y: 2, z: 3 },
{ x: 7, y: 8, z: 9 },
{ x: 2, y: 4, z: 8 }
],
arrays: [
{ x: [1, 2, 3], y: [4, 5, 6] },
{ x: [7, 8, 9], y: [0, 1, 2] }
]
});
test.done();
};
exports.testEmptyInlineTables = function(test) {
// https://github.com/BinaryMuse/toml-node/issues/24
var str = "a = { }";
test.parsesToml(str, {
a: {}
});
test.done();
};
exports.testKeyNamesWithWhitespaceAroundStartAndFinish = function(test) {
var str = "[ a ]\nb = 1";
test.parsesToml(str, {
a: {
b: 1
}
});
test.done();
};
exports.testKeyNamesWithWhitespaceAroundDots = function(test) {
var str = "[ a . b . c]\nd = 1";
test.parsesToml(str, {
a: {
b: {
c: {
d: 1
}
}
}
});
test.done();
};
exports.testSimpleQuotedKeyNames = function(test) {
var str = "[\"ʞ\"]\na = 1";
test.parsesToml(str, {
"ʞ": {
a: 1
}
});
test.done();
};
exports.testComplexQuotedKeyNames = function(test) {
var str = "[ a . \"ʞ\" . c ]\nd = 1";
test.parsesToml(str, {
a: {
"ʞ": {
c: {
d: 1
}
}
}
});
test.done();
};
exports.testEscapedQuotesInQuotedKeyNames = function(test) {
test.parsesToml("[\"the \\\"thing\\\"\"]\na = true", {
'the "thing"': {
a: true
}
});
test.done();
};
exports.testMoreComplexQuotedKeyNames = function(test) {
// https://github.com/BinaryMuse/toml-node/issues/21
test.parsesToml('["the\\ key"]\n\none = "one"\ntwo = 2\nthree = false', {
"the\\ key": {
one: "one",
two: 2,
three: false
}
});
test.parsesToml('[a."the\\ key"]\n\none = "one"\ntwo = 2\nthree = false', {
a: {
"the\\ key": {
one: "one",
two: 2,
three: false
}
}
});
test.parsesToml('[a."the-key"]\n\none = "one"\ntwo = 2\nthree = false', {
a: {
"the-key": {
one: "one",
two: 2,
three: false
}
}
});
test.parsesToml('[a."the.key"]\n\none = "one"\ntwo = 2\nthree = false', {
a: {
"the.key": {
one: "one",
two: 2,
three: false
}
}
});
// https://github.com/BinaryMuse/toml-node/issues/34
test.parsesToml('[table]\n\'a "quoted value"\' = "value"', {
table: {
'a "quoted value"': "value"
}
});
// https://github.com/BinaryMuse/toml-node/issues/33
test.parsesToml('[module]\n"foo=bar" = "zzz"', {
module: {
"foo=bar": "zzz"
}
});
test.done();
};
exports.testErrorOnBadUnicode = function(test) {
var str = "str = \"My name is Jos\\uD800\"";
test.throws(function() {
toml.parse(str);
});
test.done();
};
exports.testErrorOnDotAtStartOfKey = function(test) {
test.throws(function() {
var str = "[.a]\nb = 1";
toml.parse(str);
});
test.done()
};
exports.testErrorOnDotAtEndOfKey = function(test) {
test.throws(function() {
var str = "[.a]\nb = 1";
toml.parse(str);
});
test.done()
};
exports.testErrorOnTableOverride = function(test) {
test.throws(function() {
var str = "[a]\nb = 1\n\n[a]\nc = 2";
toml.parse(str);
});
test.done()
};
exports.testErrorOnKeyOverride = function(test) {
test.throws(function() {
var str = "[a]\nb = 1\n[a.b]\nc = 2";
toml.parse(str);
});
test.done()
};
exports.testErrorOnKeyOverrideWithNested = function(test) {
// https://github.com/BinaryMuse/toml-node/issues/23
test.throws(function() {
var str = "[a]\nb = \"a\"\n[a.b.c]";
toml.parse(str);
}, "existing key 'a.b'");
test.done();
};
exports.testErrorOnKeyOverrideWithArrayTable = function(test) {
test.throws(function() {
var str = "[a]\nb = 1\n[[a]]\nc = 2";
toml.parse(str);
});
test.done()
};
exports.testErrorOnKeyReplace = function(test) {
test.throws(function() {
var str = "[a]\nb = 1\nb = 2";
toml.parse(str);
});
test.done()
};
exports.testErrorOnInlineTableReplace = function(test) {
// https://github.com/BinaryMuse/toml-node/issues/25
test.throws(function() {
var str = "a = { b = 1 }\n[a]\nc = 2";
toml.parse(str);
}, "existing key 'a'");
test.done();
};
exports.testErrorOnArrayMismatch = function(test) {
test.throws(function() {
var str = 'data = [1, 2, "test"]'
toml.parse(str);
});
test.done();
};
exports.testErrorOnBadInputs = function(test) {
var count = 0;
for (i in badInputs) {
(function(num) {
test.throws(function() {
toml.parse(badInputs[num]);
});
})(i);
}
test.done();
};
exports.testErrorsHaveCorrectLineAndColumn = function(test) {
var str = "[a]\nb = 1\n [a.b]\nc = 2";
try { toml.parse(str); }
catch (e) {
test.equal(e.line, 3);
test.equal(e.column, 2);
test.done();
}
};
exports.testUsingConstructorAsKey = function(test) {
test.parsesToml("[empty]\n[emptier]\n[constructor]\nconstructor = 1\n[emptiest]", {
"empty": {},
"emptier": {},
"constructor": { "constructor": 1 },
"emptiest": {}
});
test.done();
};

View File

@ -1,18 +0,0 @@
Copyright Joyent, Inc. and other Node contributors. All rights reserved.
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.

View File

@ -1,15 +0,0 @@
# util
[![Build Status](https://travis-ci.org/defunctzombie/node-util.png?branch=master)](https://travis-ci.org/defunctzombie/node-util)
node.js [util](http://nodejs.org/api/util.html) module as a module
## install via [npm](npmjs.org)
```shell
npm install util
```
## browser support
This module also works in modern browsers. If you need legacy browser support you will need to polyfill ES5 features.

View File

@ -1,16 +0,0 @@
The ISC License
Copyright (c) Isaac Z. Schlueter
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.

View File

@ -1,42 +0,0 @@
Browser-friendly inheritance fully compatible with standard node.js
[inherits](http://nodejs.org/api/util.html#util_util_inherits_constructor_superconstructor).
This package exports standard `inherits` from node.js `util` module in
node environment, but also provides alternative browser-friendly
implementation through [browser
field](https://gist.github.com/shtylman/4339901). Alternative
implementation is a literal copy of standard one located in standalone
module to avoid requiring of `util`. It also has a shim for old
browsers with no `Object.create` support.
While keeping you sure you are using standard `inherits`
implementation in node.js environment, it allows bundlers such as
[browserify](https://github.com/substack/node-browserify) to not
include full `util` package to your client code if all you need is
just `inherits` function. It worth, because browser shim for `util`
package is large and `inherits` is often the single function you need
from it.
It's recommended to use this package instead of
`require('util').inherits` for any code that has chances to be used
not only in node.js but in browser too.
## usage
```js
var inherits = require('inherits');
// then use exactly as the standard one
```
## note on version ~1.0
Version ~1.0 had completely different motivation and is not compatible
neither with 2.0 nor with standard node.js `inherits`.
If you are using version ~1.0 and planning to switch to ~2.0, be
careful:
* new version uses `super_` instead of `super` for referencing
superclass
* new version overwrites current prototype while old one preserves any
existing fields on it

View File

@ -1,7 +0,0 @@
try {
var util = require('util');
if (typeof util.inherits !== 'function') throw '';
module.exports = util.inherits;
} catch (e) {
module.exports = require('./inherits_browser.js');
}

View File

@ -1,23 +0,0 @@
if (typeof Object.create === 'function') {
// implementation from standard node.js 'util' module
module.exports = function inherits(ctor, superCtor) {
ctor.super_ = superCtor
ctor.prototype = Object.create(superCtor.prototype, {
constructor: {
value: ctor,
enumerable: false,
writable: true,
configurable: true
}
});
};
} else {
// old school shim for old browsers
module.exports = function inherits(ctor, superCtor) {
ctor.super_ = superCtor
var TempCtor = function () {}
TempCtor.prototype = superCtor.prototype
ctor.prototype = new TempCtor()
ctor.prototype.constructor = ctor
}
}

View File

@ -1,29 +0,0 @@
{
"name": "inherits",
"description": "Browser-friendly inheritance fully compatible with standard node.js inherits()",
"version": "2.0.3",
"keywords": [
"inheritance",
"class",
"klass",
"oop",
"object-oriented",
"inherits",
"browser",
"browserify"
],
"main": "./inherits.js",
"browser": "./inherits_browser.js",
"repository": "git://github.com/isaacs/inherits",
"license": "ISC",
"scripts": {
"test": "node test"
},
"devDependencies": {
"tap": "^7.1.0"
},
"files": [
"inherits.js",
"inherits_browser.js"
]
}

View File

@ -1,35 +0,0 @@
{
"author": {
"name": "Joyent",
"url": "http://www.joyent.com"
},
"name": "util",
"description": "Node.JS util module",
"keywords": [
"util"
],
"version": "0.10.4",
"homepage": "https://github.com/defunctzombie/node-util",
"repository": {
"type": "git",
"url": "git://github.com/defunctzombie/node-util"
},
"main": "./util.js",
"files": [
"util.js",
"support"
],
"scripts": {
"test": "node test/node/*.js && zuul test/browser/*.js"
},
"dependencies": {
"inherits": "2.0.3"
},
"license": "MIT",
"devDependencies": {
"zuul": "~1.0.9"
},
"browser": {
"./support/isBuffer.js": "./support/isBufferBrowser.js"
}
}

View File

@ -1,3 +0,0 @@
module.exports = function isBuffer(arg) {
return arg instanceof Buffer;
}

View File

@ -1,6 +0,0 @@
module.exports = function isBuffer(arg) {
return arg && typeof arg === 'object'
&& typeof arg.copy === 'function'
&& typeof arg.fill === 'function'
&& typeof arg.readUInt8 === 'function';
}

View File

@ -1,586 +0,0 @@
// Copyright Joyent, Inc. and other Node contributors.
//
// 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.
var formatRegExp = /%[sdj%]/g;
exports.format = function(f) {
if (!isString(f)) {
var objects = [];
for (var i = 0; i < arguments.length; i++) {
objects.push(inspect(arguments[i]));
}
return objects.join(' ');
}
var i = 1;
var args = arguments;
var len = args.length;
var str = String(f).replace(formatRegExp, function(x) {
if (x === '%%') return '%';
if (i >= len) return x;
switch (x) {
case '%s': return String(args[i++]);
case '%d': return Number(args[i++]);
case '%j':
try {
return JSON.stringify(args[i++]);
} catch (_) {
return '[Circular]';
}
default:
return x;
}
});
for (var x = args[i]; i < len; x = args[++i]) {
if (isNull(x) || !isObject(x)) {
str += ' ' + x;
} else {
str += ' ' + inspect(x);
}
}
return str;
};
// Mark that a method should not be used.
// Returns a modified function which warns once by default.
// If --no-deprecation is set, then it is a no-op.
exports.deprecate = function(fn, msg) {
// Allow for deprecating things in the process of starting up.
if (isUndefined(global.process)) {
return function() {
return exports.deprecate(fn, msg).apply(this, arguments);
};
}
if (process.noDeprecation === true) {
return fn;
}
var warned = false;
function deprecated() {
if (!warned) {
if (process.throwDeprecation) {
throw new Error(msg);
} else if (process.traceDeprecation) {
console.trace(msg);
} else {
console.error(msg);
}
warned = true;
}
return fn.apply(this, arguments);
}
return deprecated;
};
var debugs = {};
var debugEnviron;
exports.debuglog = function(set) {
if (isUndefined(debugEnviron))
debugEnviron = process.env.NODE_DEBUG || '';
set = set.toUpperCase();
if (!debugs[set]) {
if (new RegExp('\\b' + set + '\\b', 'i').test(debugEnviron)) {
var pid = process.pid;
debugs[set] = function() {
var msg = exports.format.apply(exports, arguments);
console.error('%s %d: %s', set, pid, msg);
};
} else {
debugs[set] = function() {};
}
}
return debugs[set];
};
/**
* Echos the value of a value. Trys to print the value out
* in the best way possible given the different types.
*
* @param {Object} obj The object to print out.
* @param {Object} opts Optional options object that alters the output.
*/
/* legacy: obj, showHidden, depth, colors*/
function inspect(obj, opts) {
// default options
var ctx = {
seen: [],
stylize: stylizeNoColor
};
// legacy...
if (arguments.length >= 3) ctx.depth = arguments[2];
if (arguments.length >= 4) ctx.colors = arguments[3];
if (isBoolean(opts)) {
// legacy...
ctx.showHidden = opts;
} else if (opts) {
// got an "options" object
exports._extend(ctx, opts);
}
// set default options
if (isUndefined(ctx.showHidden)) ctx.showHidden = false;
if (isUndefined(ctx.depth)) ctx.depth = 2;
if (isUndefined(ctx.colors)) ctx.colors = false;
if (isUndefined(ctx.customInspect)) ctx.customInspect = true;
if (ctx.colors) ctx.stylize = stylizeWithColor;
return formatValue(ctx, obj, ctx.depth);
}
exports.inspect = inspect;
// http://en.wikipedia.org/wiki/ANSI_escape_code#graphics
inspect.colors = {
'bold' : [1, 22],
'italic' : [3, 23],
'underline' : [4, 24],
'inverse' : [7, 27],
'white' : [37, 39],
'grey' : [90, 39],
'black' : [30, 39],
'blue' : [34, 39],
'cyan' : [36, 39],
'green' : [32, 39],
'magenta' : [35, 39],
'red' : [31, 39],
'yellow' : [33, 39]
};
// Don't use 'blue' not visible on cmd.exe
inspect.styles = {
'special': 'cyan',
'number': 'yellow',
'boolean': 'yellow',
'undefined': 'grey',
'null': 'bold',
'string': 'green',
'date': 'magenta',
// "name": intentionally not styling
'regexp': 'red'
};
function stylizeWithColor(str, styleType) {
var style = inspect.styles[styleType];
if (style) {
return '\u001b[' + inspect.colors[style][0] + 'm' + str +
'\u001b[' + inspect.colors[style][1] + 'm';
} else {
return str;
}
}
function stylizeNoColor(str, styleType) {
return str;
}
function arrayToHash(array) {
var hash = {};
array.forEach(function(val, idx) {
hash[val] = true;
});
return hash;
}
function formatValue(ctx, value, recurseTimes) {
// Provide a hook for user-specified inspect functions.
// Check that value is an object with an inspect function on it
if (ctx.customInspect &&
value &&
isFunction(value.inspect) &&
// Filter out the util module, it's inspect function is special
value.inspect !== exports.inspect &&
// Also filter out any prototype objects using the circular check.
!(value.constructor && value.constructor.prototype === value)) {
var ret = value.inspect(recurseTimes, ctx);
if (!isString(ret)) {
ret = formatValue(ctx, ret, recurseTimes);
}
return ret;
}
// Primitive types cannot have properties
var primitive = formatPrimitive(ctx, value);
if (primitive) {
return primitive;
}
// Look up the keys of the object.
var keys = Object.keys(value);
var visibleKeys = arrayToHash(keys);
if (ctx.showHidden) {
keys = Object.getOwnPropertyNames(value);
}
// IE doesn't make error fields non-enumerable
// http://msdn.microsoft.com/en-us/library/ie/dww52sbt(v=vs.94).aspx
if (isError(value)
&& (keys.indexOf('message') >= 0 || keys.indexOf('description') >= 0)) {
return formatError(value);
}
// Some type of object without properties can be shortcutted.
if (keys.length === 0) {
if (isFunction(value)) {
var name = value.name ? ': ' + value.name : '';
return ctx.stylize('[Function' + name + ']', 'special');
}
if (isRegExp(value)) {
return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
}
if (isDate(value)) {
return ctx.stylize(Date.prototype.toString.call(value), 'date');
}
if (isError(value)) {
return formatError(value);
}
}
var base = '', array = false, braces = ['{', '}'];
// Make Array say that they are Array
if (isArray(value)) {
array = true;
braces = ['[', ']'];
}
// Make functions say that they are functions
if (isFunction(value)) {
var n = value.name ? ': ' + value.name : '';
base = ' [Function' + n + ']';
}
// Make RegExps say that they are RegExps
if (isRegExp(value)) {
base = ' ' + RegExp.prototype.toString.call(value);
}
// Make dates with properties first say the date
if (isDate(value)) {
base = ' ' + Date.prototype.toUTCString.call(value);
}
// Make error with message first say the error
if (isError(value)) {
base = ' ' + formatError(value);
}
if (keys.length === 0 && (!array || value.length == 0)) {
return braces[0] + base + braces[1];
}
if (recurseTimes < 0) {
if (isRegExp(value)) {
return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
} else {
return ctx.stylize('[Object]', 'special');
}
}
ctx.seen.push(value);
var output;
if (array) {
output = formatArray(ctx, value, recurseTimes, visibleKeys, keys);
} else {
output = keys.map(function(key) {
return formatProperty(ctx, value, recurseTimes, visibleKeys, key, array);
});
}
ctx.seen.pop();
return reduceToSingleString(output, base, braces);
}
function formatPrimitive(ctx, value) {
if (isUndefined(value))
return ctx.stylize('undefined', 'undefined');
if (isString(value)) {
var simple = '\'' + JSON.stringify(value).replace(/^"|"$/g, '')
.replace(/'/g, "\\'")
.replace(/\\"/g, '"') + '\'';
return ctx.stylize(simple, 'string');
}
if (isNumber(value))
return ctx.stylize('' + value, 'number');
if (isBoolean(value))
return ctx.stylize('' + value, 'boolean');
// For some reason typeof null is "object", so special case here.
if (isNull(value))
return ctx.stylize('null', 'null');
}
function formatError(value) {
return '[' + Error.prototype.toString.call(value) + ']';
}
function formatArray(ctx, value, recurseTimes, visibleKeys, keys) {
var output = [];
for (var i = 0, l = value.length; i < l; ++i) {
if (hasOwnProperty(value, String(i))) {
output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
String(i), true));
} else {
output.push('');
}
}
keys.forEach(function(key) {
if (!key.match(/^\d+$/)) {
output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
key, true));
}
});
return output;
}
function formatProperty(ctx, value, recurseTimes, visibleKeys, key, array) {
var name, str, desc;
desc = Object.getOwnPropertyDescriptor(value, key) || { value: value[key] };
if (desc.get) {
if (desc.set) {
str = ctx.stylize('[Getter/Setter]', 'special');
} else {
str = ctx.stylize('[Getter]', 'special');
}
} else {
if (desc.set) {
str = ctx.stylize('[Setter]', 'special');
}
}
if (!hasOwnProperty(visibleKeys, key)) {
name = '[' + key + ']';
}
if (!str) {
if (ctx.seen.indexOf(desc.value) < 0) {
if (isNull(recurseTimes)) {
str = formatValue(ctx, desc.value, null);
} else {
str = formatValue(ctx, desc.value, recurseTimes - 1);
}
if (str.indexOf('\n') > -1) {
if (array) {
str = str.split('\n').map(function(line) {
return ' ' + line;
}).join('\n').substr(2);
} else {
str = '\n' + str.split('\n').map(function(line) {
return ' ' + line;
}).join('\n');
}
}
} else {
str = ctx.stylize('[Circular]', 'special');
}
}
if (isUndefined(name)) {
if (array && key.match(/^\d+$/)) {
return str;
}
name = JSON.stringify('' + key);
if (name.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)) {
name = name.substr(1, name.length - 2);
name = ctx.stylize(name, 'name');
} else {
name = name.replace(/'/g, "\\'")
.replace(/\\"/g, '"')
.replace(/(^"|"$)/g, "'");
name = ctx.stylize(name, 'string');
}
}
return name + ': ' + str;
}
function reduceToSingleString(output, base, braces) {
var numLinesEst = 0;
var length = output.reduce(function(prev, cur) {
numLinesEst++;
if (cur.indexOf('\n') >= 0) numLinesEst++;
return prev + cur.replace(/\u001b\[\d\d?m/g, '').length + 1;
}, 0);
if (length > 60) {
return braces[0] +
(base === '' ? '' : base + '\n ') +
' ' +
output.join(',\n ') +
' ' +
braces[1];
}
return braces[0] + base + ' ' + output.join(', ') + ' ' + braces[1];
}
// NOTE: These type checking functions intentionally don't use `instanceof`
// because it is fragile and can be easily faked with `Object.create()`.
function isArray(ar) {
return Array.isArray(ar);
}
exports.isArray = isArray;
function isBoolean(arg) {
return typeof arg === 'boolean';
}
exports.isBoolean = isBoolean;
function isNull(arg) {
return arg === null;
}
exports.isNull = isNull;
function isNullOrUndefined(arg) {
return arg == null;
}
exports.isNullOrUndefined = isNullOrUndefined;
function isNumber(arg) {
return typeof arg === 'number';
}
exports.isNumber = isNumber;
function isString(arg) {
return typeof arg === 'string';
}
exports.isString = isString;
function isSymbol(arg) {
return typeof arg === 'symbol';
}
exports.isSymbol = isSymbol;
function isUndefined(arg) {
return arg === void 0;
}
exports.isUndefined = isUndefined;
function isRegExp(re) {
return isObject(re) && objectToString(re) === '[object RegExp]';
}
exports.isRegExp = isRegExp;
function isObject(arg) {
return typeof arg === 'object' && arg !== null;
}
exports.isObject = isObject;
function isDate(d) {
return isObject(d) && objectToString(d) === '[object Date]';
}
exports.isDate = isDate;
function isError(e) {
return isObject(e) &&
(objectToString(e) === '[object Error]' || e instanceof Error);
}
exports.isError = isError;
function isFunction(arg) {
return typeof arg === 'function';
}
exports.isFunction = isFunction;
function isPrimitive(arg) {
return arg === null ||
typeof arg === 'boolean' ||
typeof arg === 'number' ||
typeof arg === 'string' ||
typeof arg === 'symbol' || // ES6 symbol
typeof arg === 'undefined';
}
exports.isPrimitive = isPrimitive;
exports.isBuffer = require('./support/isBuffer');
function objectToString(o) {
return Object.prototype.toString.call(o);
}
function pad(n) {
return n < 10 ? '0' + n.toString(10) : n.toString(10);
}
var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep',
'Oct', 'Nov', 'Dec'];
// 26 Feb 16:19:34
function timestamp() {
var d = new Date();
var time = [pad(d.getHours()),
pad(d.getMinutes()),
pad(d.getSeconds())].join(':');
return [d.getDate(), months[d.getMonth()], time].join(' ');
}
// log is just a thin wrapper to console.log that prepends a timestamp
exports.log = function() {
console.log('%s - %s', timestamp(), exports.format.apply(exports, arguments));
};
/**
* Inherit the prototype methods from one constructor into another.
*
* The Function.prototype.inherits from lang.js rewritten as a standalone
* function (not on Function.prototype). NOTE: If this file is to be loaded
* during bootstrapping this function needs to be rewritten using some native
* functions as prototype setup using normal JavaScript does not work as
* expected during bootstrapping (see mirror.js in r114903).
*
* @param {function} ctor Constructor function which needs to inherit the
* prototype.
* @param {function} superCtor Constructor function to inherit prototype from.
*/
exports.inherits = require('inherits');
exports._extend = function(origin, add) {
// Don't do anything if add isn't an object
if (!add || !isObject(add)) return origin;
var keys = Object.keys(add);
var i = keys.length;
while (i--) {
origin[keys[i]] = add[keys[i]];
}
return origin;
};
function hasOwnProperty(obj, prop) {
return Object.prototype.hasOwnProperty.call(obj, prop);
}

View File

@ -1,54 +0,0 @@
'use strict';
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.DjangoCompletionItemProvider = void 0;
const vscode_1 = require("vscode");
const constants_1 = require("../constants");
const settings = vscode_1.workspace.getConfiguration("django");
const exclusions = settings.snippets.exclude;
class DjangoCompletionItemProvider {
constructor() {
this.selector = constants_1.PYTHON_SELECTOR;
this.directory = '';
this.files = [];
this.snippets = [];
}
loadSnippets(snippetPrvider) {
return __awaiter(this, void 0, void 0, function* () {
if (!settings.snippets.use)
return;
if (exclusions.some(word => this.directory.includes(word)))
return;
this.snippets = Array.prototype.concat(...yield Promise.all(this.files.filter(file => !exclusions.some(word => file.includes(word)))
.map(file => snippetPrvider.readSnippets(`${this.directory}/${file}`))));
if (!settings.i18n) {
this.snippets = this.snippets.map(snippet => {
snippet.body = snippet.body.replace(/_\("(\S*)"\)/g, '"$1"');
return snippet;
});
}
});
}
buildSnippet(snippet) {
let item = new vscode_1.CompletionItem(snippet.prefix, vscode_1.CompletionItemKind.Snippet);
item.insertText = new vscode_1.SnippetString(snippet.body);
item.detail = snippet.detail;
item.documentation = new vscode_1.MarkdownString(snippet.description);
return item;
}
provideCompletionItems(document, position, token, context) {
return __awaiter(this, void 0, void 0, function* () {
return this.snippets.map(this.buildSnippet);
});
}
}
exports.DjangoCompletionItemProvider = DjangoCompletionItemProvider;
//# sourceMappingURL=base.js.map

View File

@ -1,96 +0,0 @@
'use strict';
Object.defineProperty(exports, "__esModule", { value: true });
exports.DjangoUrlCompletionItemProvider = exports.DjangoTemplatetagsCompletionItemProvider = exports.DjangoViewCompletionItemProvider = exports.DjangoModelCompletionItemProvider = exports.DjangoMigrationCompletionItemProvider = exports.DjangoManagerCompletionItemProvider = exports.DjangoFormCompletionItemProvider = exports.DjangoAdminCompletionItemProvider = exports.DjangoPythonCompletionItemProvider = void 0;
const constants_1 = require("../constants");
const base_1 = require("./base");
class DjangoPythonCompletionItemProvider extends base_1.DjangoCompletionItemProvider {
constructor(snippetPrvider) {
super();
this.selector = constants_1.PYTHON_SELECTOR;
this.directory = 'python';
this.files = ["imports.toml", "utils.toml"];
this.loadSnippets(snippetPrvider);
}
}
exports.DjangoPythonCompletionItemProvider = DjangoPythonCompletionItemProvider;
class DjangoAdminCompletionItemProvider extends base_1.DjangoCompletionItemProvider {
constructor(snippetPrvider) {
super();
this.selector = Object.assign({ pattern: '**/admin{**/,}*.py' }, constants_1.PYTHON_SELECTOR);
this.directory = "admin";
this.files = ["classes.toml", "imports.toml", "options.toml"];
this.loadSnippets(snippetPrvider);
}
}
exports.DjangoAdminCompletionItemProvider = DjangoAdminCompletionItemProvider;
class DjangoFormCompletionItemProvider extends base_1.DjangoCompletionItemProvider {
constructor(snippetPrvider) {
super();
this.selector = Object.assign({ pattern: '**/forms{**/,}*.py' }, constants_1.PYTHON_SELECTOR);
this.directory = "forms";
this.files = ["classes.toml", "imports.toml", "fields.toml", "fields-postgres.toml", "methods.toml"];
this.loadSnippets(snippetPrvider);
}
}
exports.DjangoFormCompletionItemProvider = DjangoFormCompletionItemProvider;
class DjangoManagerCompletionItemProvider extends base_1.DjangoCompletionItemProvider {
constructor(snippetPrvider) {
super();
this.selector = Object.assign({ pattern: '**/{models,managers,querysets}{**/,}*.py' }, constants_1.PYTHON_SELECTOR);
this.directory = "models";
this.files = ["managers.toml"];
this.loadSnippets(snippetPrvider);
}
}
exports.DjangoManagerCompletionItemProvider = DjangoManagerCompletionItemProvider;
class DjangoMigrationCompletionItemProvider extends base_1.DjangoCompletionItemProvider {
constructor(snippetPrvider) {
super();
this.selector = Object.assign({ pattern: '**/migrations/**/*.py' }, constants_1.PYTHON_SELECTOR);
this.directory = "models";
this.files = ["migrations.toml"];
this.loadSnippets(snippetPrvider);
}
}
exports.DjangoMigrationCompletionItemProvider = DjangoMigrationCompletionItemProvider;
class DjangoModelCompletionItemProvider extends base_1.DjangoCompletionItemProvider {
constructor(snippetPrvider) {
super();
this.selector = Object.assign({ pattern: '**/{models,migrations}{**/,}*.py' }, constants_1.PYTHON_SELECTOR);
this.directory = "models";
this.files = ["classes.toml", "imports.toml", "fields.toml", "fields-postgres.toml", "methods.toml"];
this.loadSnippets(snippetPrvider);
}
}
exports.DjangoModelCompletionItemProvider = DjangoModelCompletionItemProvider;
class DjangoViewCompletionItemProvider extends base_1.DjangoCompletionItemProvider {
constructor(snippetPrvider) {
super();
this.selector = Object.assign({ pattern: '**/views{**/,}*.py' }, constants_1.PYTHON_SELECTOR);
this.directory = "views";
this.files = ["classes.toml", "imports.toml", "methods.toml"];
this.loadSnippets(snippetPrvider);
}
}
exports.DjangoViewCompletionItemProvider = DjangoViewCompletionItemProvider;
class DjangoTemplatetagsCompletionItemProvider extends base_1.DjangoCompletionItemProvider {
constructor(snippetPrvider) {
super();
this.selector = Object.assign({ pattern: '**/templatetags/**/*.py' }, constants_1.PYTHON_SELECTOR);
this.directory = "templatetags";
this.files = ["imports.toml", "methods.toml"];
this.loadSnippets(snippetPrvider);
}
}
exports.DjangoTemplatetagsCompletionItemProvider = DjangoTemplatetagsCompletionItemProvider;
class DjangoUrlCompletionItemProvider extends base_1.DjangoCompletionItemProvider {
constructor(snippetPrvider) {
super();
this.selector = Object.assign({ pattern: '**/urls{**/,}*.py' }, constants_1.PYTHON_SELECTOR);
this.directory = "urls";
this.files = ["imports.toml", "methods.toml", "regexes.toml"];
this.loadSnippets(snippetPrvider);
}
}
exports.DjangoUrlCompletionItemProvider = DjangoUrlCompletionItemProvider;
//# sourceMappingURL=completionItemProvider.js.map

View File

@ -1,6 +0,0 @@
'use strict';
Object.defineProperty(exports, "__esModule", { value: true });
exports.PYTHON_SELECTOR = exports.DJANGO_HTML_SELECTOR = void 0;
exports.DJANGO_HTML_SELECTOR = { scheme: 'file', language: 'django-html' };
exports.PYTHON_SELECTOR = { scheme: 'file', language: 'python' };
//# sourceMappingURL=constants.js.map

File diff suppressed because it is too large Load Diff

View File

@ -1,44 +0,0 @@
'use strict';
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.activate = void 0;
const vscode_1 = require("vscode");
const definitionProvider_1 = require("./providers/definitionProvider");
const completionItemProvider_1 = require("./completions/completionItemProvider");
const utils_1 = require("./utils");
function activate(context) {
return __awaiter(this, void 0, void 0, function* () {
const snippetProvider = new utils_1.SnippetProvider(context.extensionUri);
const definitions = new definitionProvider_1.TemplatePathProvider();
context.subscriptions.push(vscode_1.languages.registerDefinitionProvider(definitions.selector, definitions));
const djangoPythonSnippets = new completionItemProvider_1.DjangoPythonCompletionItemProvider(snippetProvider);
context.subscriptions.push(vscode_1.languages.registerCompletionItemProvider(djangoPythonSnippets.selector, djangoPythonSnippets));
const djangoAdminSnippets = new completionItemProvider_1.DjangoAdminCompletionItemProvider(snippetProvider);
context.subscriptions.push(vscode_1.languages.registerCompletionItemProvider(djangoAdminSnippets.selector, djangoAdminSnippets));
const djangoFormSnippets = new completionItemProvider_1.DjangoFormCompletionItemProvider(snippetProvider);
context.subscriptions.push(vscode_1.languages.registerCompletionItemProvider(djangoFormSnippets.selector, djangoFormSnippets));
const djangoManagerSnippets = new completionItemProvider_1.DjangoManagerCompletionItemProvider(snippetProvider);
context.subscriptions.push(vscode_1.languages.registerCompletionItemProvider(djangoManagerSnippets.selector, djangoManagerSnippets));
const djangoMigrationSnippets = new completionItemProvider_1.DjangoMigrationCompletionItemProvider(snippetProvider);
context.subscriptions.push(vscode_1.languages.registerCompletionItemProvider(djangoMigrationSnippets.selector, djangoMigrationSnippets));
const djangoModelSnippets = new completionItemProvider_1.DjangoModelCompletionItemProvider(snippetProvider);
context.subscriptions.push(vscode_1.languages.registerCompletionItemProvider(djangoModelSnippets.selector, djangoModelSnippets));
const djangoViewSnippets = new completionItemProvider_1.DjangoViewCompletionItemProvider(snippetProvider);
context.subscriptions.push(vscode_1.languages.registerCompletionItemProvider(djangoViewSnippets.selector, djangoViewSnippets));
const djangoTemplatetagsSnippets = new completionItemProvider_1.DjangoTemplatetagsCompletionItemProvider(snippetProvider);
context.subscriptions.push(vscode_1.languages.registerCompletionItemProvider(djangoTemplatetagsSnippets.selector, djangoTemplatetagsSnippets));
const djangoUrlSnippets = new completionItemProvider_1.DjangoUrlCompletionItemProvider(snippetProvider);
context.subscriptions.push(vscode_1.languages.registerCompletionItemProvider(djangoUrlSnippets.selector, djangoUrlSnippets));
(0, utils_1.postInitHook)();
});
}
exports.activate = activate;
//# sourceMappingURL=extension.js.map

View File

@ -1,66 +0,0 @@
'use strict';
Object.defineProperty(exports, "__esModule", { value: true });
exports.TemplatePathProvider = void 0;
const path_1 = require("path");
const vscode_1 = require("vscode");
const constants_1 = require("../constants");
let regex = (regexes) => new RegExp(regexes.map(re => re.source).join(''));
const quote = /(?:\'|\")/;
const path_re = /([\w/\-]+\.[\w]+)/;
const rel_path_re = /((?:(?:\.\/|(?:\.\.\/)+))[\w/\-]+\.[\w]+)/;
const PATH_RE = regex([quote, path_re, quote]);
const RELATIVE_PATH_RE = regex([quote, rel_path_re, quote]);
const BEGIN_OF_FILE = new vscode_1.Position(0, 0);
let cache = {};
class TemplatePathProvider {
constructor() {
this.selector = [constants_1.DJANGO_HTML_SELECTOR, constants_1.PYTHON_SELECTOR];
}
static getTemplate(document, position, token) {
let path;
let search;
let line = document.lineAt(position.line).text;
let match = line.match(PATH_RE);
let relative_match = line.match(RELATIVE_PATH_RE);
if (relative_match) {
path = relative_match[1];
search = vscode_1.workspace.asRelativePath((0, path_1.resolve)((0, path_1.dirname)(document.uri.path), path));
}
else if (match) {
path = match[1];
search = `**/{templates,jinja2}/${path}`;
}
else {
return Promise.resolve(null);
}
let pos = position.character;
let cursorOverPath = pos > line.indexOf(path) && pos < line.indexOf(path) + path.length;
let uri;
if (search in cache) {
uri = Promise.resolve(cache[search]);
}
else {
uri = vscode_1.workspace.findFiles(search, '', 1, token).then(results => {
let result = results.length ? results[0] : null;
if (result)
cache[search] = result;
return result;
});
}
if (cursorOverPath) {
return uri;
}
else {
return Promise.resolve(null);
}
}
provideDefinition(document, position, token) {
return TemplatePathProvider.getTemplate(document, position, token).then(template => {
if (!template)
return null;
return new vscode_1.Location(template, BEGIN_OF_FILE);
});
}
}
exports.TemplatePathProvider = TemplatePathProvider;
//# sourceMappingURL=definitionProvider.js.map

View File

@ -1,34 +0,0 @@
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.postInitHook = exports.SnippetProvider = void 0;
const toml = require("toml");
const vscode = require("vscode");
const util_1 = require("util");
class SnippetProvider {
constructor(extensionUri) {
this.extensionUri = extensionUri;
}
readSnippets(name) {
return __awaiter(this, void 0, void 0, function* () {
const location = vscode.Uri.joinPath(this.extensionUri, 'completions/snippets', name);
const buffer = yield vscode.workspace.fs.readFile(location);
const str = new util_1.TextDecoder("utf-8").decode(buffer);
return toml.parse(str).snippets;
});
}
}
exports.SnippetProvider = SnippetProvider;
function postInitHook() {
return __awaiter(this, void 0, void 0, function* () { });
}
exports.postInitHook = postInitHook;
//# sourceMappingURL=utils.js.map

View File

@ -1,191 +0,0 @@
{
"name": "vscode-django",
"displayName": "Django",
"description": "Beautiful syntax and scoped snippets for perfectionists with deadlines",
"version": "1.15.0",
"publisher": "batisteo",
"license": "MIT",
"icon": "images/vscode-django-icon.png",
"galleryBanner": {
"color": "#0c4b33",
"theme": "dark"
},
"engines": {
"vscode": "^1.49.0"
},
"recommendations": [
"ms-python.python"
],
"keywords": [
"python",
"django",
"web"
],
"categories": [
"Programming Languages",
"Snippets"
],
"homepage": "https://github.com/vscode-django/vscode-django",
"repository": {
"type": "git",
"url": "https://github.com/vscode-django/vscode-django"
},
"bugs": {
"url": "https://github.com/vscode-django/vscode-django/issues"
},
"activationEvents": [
"onLanguage:django-html",
"onLanguage:django-txt",
"onLanguage:python"
],
"main": "./out/extension",
"browser": "./out/extension-web",
"scripts": {
"vscode:prepublish": "yarn run compile",
"compile": "tsc -p ./",
"lint": "eslint src --ext ts",
"watch": "tsc -watch -p ./",
"pretest": "yarn run compile && yarn run lint",
"test": "yarn run compile && node ./node_modules/vscode/bin/test",
"compile-web": "webpack",
"watch-web": "webpack",
"package-web": "webpack --mode production --devtool hidden-source-map",
"chrome": "vscode-test-web --browserType=chromium --extensionDevelopmentPath=. ."
},
"dependencies": {
"path": "^0.12.7",
"toml": "^3"
},
"devDependencies": {
"@types/glob": "^7.1.3",
"@types/mocha": "^8.0.0",
"@types/node": "^12.11.7",
"@types/vscode": "^1.48.0",
"@typescript-eslint/eslint-plugin": "^4.1.1",
"@typescript-eslint/parser": "^4.1.1",
"eslint": "^7.9.0",
"glob": "^7.1.6",
"mocha": "^8.1.3",
"typescript": "^4.0.2",
"vscode-test": "^1.4.0",
"ts-loader": "^9.2.2",
"webpack": "^5.38.1",
"webpack-cli": "^4.7.0",
"@vscode/test-web": "^0.0.11"
},
"contributes": {
"commands": [
{
"command": "extension.Message",
"title": "Message"
}
],
"languages": [
{
"id": "django-html",
"aliases": [
"Django HTML",
"django"
],
"filenamePatterns": [
"**/templates/**/*.html"
],
"firstLine": "{%",
"configuration": "./language-configuration.json"
},
{
"id": "django-txt",
"aliases": [
"Django txt",
"django"
],
"filenamePatterns": [
"**/templates/**/*"
],
"firstLine": "{%",
"configuration": "./language-configuration.json"
}
],
"grammars": [
{
"language": "django-html",
"scopeName": "text.html.django",
"path": "./syntaxes/django-html.tmLanguage.json"
},
{
"language": "django-txt",
"scopeName": "text.django",
"path": "./syntaxes/django-txt.tmLanguage.json"
}
],
"snippets": [
{
"language": "django-html",
"path": "./snippets/templates/tags.json"
},
{
"language": "django-html",
"path": "./snippets/templates/filters.json"
},
{
"language": "django-txt",
"path": "./snippets/templates/tags.json"
},
{
"language": "django-txt",
"path": "./snippets/templates/filters.json"
}
],
"configurationDefaults": {
"[django-html]": {
"editor.quickSuggestions": {
"other": true,
"comments": true,
"strings": true
}
}
},
"configuration": {
"type": "object",
"title": "Django configuration",
"properties": {
"django.snippets.use": {
"type": "boolean",
"default": true,
"description": "Activates the Python snippets"
},
"django.snippets.exclude": {
"type": "array",
"default": [
"cms",
"wagtail"
],
"description": "Exclude Python snippets by their file name. Can be 'import', 'postgres'..."
},
"django.i18n": {
"type": "boolean",
"default": true,
"description": "Activates the i18n features for snippets (eg.: _(\"\"))"
},
"django.showContributeNotification": {
"type": "boolean",
"default": true,
"description": "Seldom show notifications about this extension"
}
}
}
},
"__metadata": {
"id": "4b41a5a8-170e-4156-b2c0-10efb270abbc",
"publisherId": "f87b3a80-eb31-405d-a27d-a2d02be8cc0f",
"publisherDisplayName": "Baptiste Darthenay",
"targetPlatform": "undefined",
"isApplicationScoped": false,
"isPreReleaseVersion": false,
"hasPreReleaseVersion": false,
"installedTimestamp": 1718224747414,
"pinned": false,
"preRelease": false,
"source": "gallery"
}
}

View File

@ -1,339 +0,0 @@
{
"_comment" : "This section is autocomplete for django template filters",
"join": {
"description": "Filter |join:\", \"",
"prefix": "join",
"body": "join:${1:\", \"}$0"
},
"addslashes": {
"description": "Filter |addslashes",
"prefix": "addslashes",
"body": "addslashes"
},
"capfirst": {
"description": "Filter |capfirst",
"prefix": "capfirst",
"body": "capfirst"
},
"escapejs": {
"description": "Filter |escapejs",
"prefix": "escapejs",
"body": "escapejs"
},
"floatformat": {
"description": "Filter |floatformat",
"prefix": "floatformat",
"body": "floatformat"
},
"iriencode": {
"description": "Filter |iriencode",
"prefix": "iriencode",
"body": "iriencode"
},
"linenumbers": {
"description": "Filter |linenumbers",
"prefix": "linenumbers",
"body": "linenumbers"
},
"lower": {
"description": "Filter |lower",
"prefix": "lower",
"body": "lower"
},
"make_list": {
"description": "Filter |make_list",
"prefix": "make_list",
"body": "make_list"
},
"slugify": {
"description": "Filter |slugify",
"prefix": "slugify",
"body": "slugify"
},
"stringformat": {
"description": "Filter |stringformat",
"prefix": "stringformat",
"body": "stringformat"
},
"title": {
"description": "Filter |title",
"prefix": "title",
"body": "title"
},
"truncatechars": {
"description": "Filter |truncatechars",
"prefix": "truncatechars",
"body": "truncatechars"
},
"truncatechars_html": {
"description": "Filter |stuff:', truncatechars_html",
"prefix": "truncatechars_html",
"body": "truncatechars_html"
},
"truncatewords": {
"description": "Filter |truncatewords",
"prefix": "truncatewords",
"body": "truncatewords"
},
"truncatewords_html": {
"description": "Filter |stuff:', truncatewords_html",
"prefix": "truncatewords_html",
"body": "truncatewords_html"
},
"upper": {
"description": "Filter |upper",
"prefix": "upper",
"body": "upper"
},
"urlencode": {
"description": "Filter |urlencode",
"prefix": "urlencode",
"body": "urlencode"
},
"urlize": {
"description": "Filter |urlize",
"prefix": "urlize",
"body": "urlize"
},
"urlizetrunc": {
"description": "Filter |urlizetrunc",
"prefix": "urlizetrunc",
"body": "urlizetrunc"
},
"wordcount": {
"description": "Filter |wordcount",
"prefix": "wordcount",
"body": "wordcount"
},
"wordwrap": {
"description": "Filter |wordwrap:number",
"prefix": "wordwrap",
"body": "wordwrap:$1"
},
"ljust": {
"description": "Filter |ljust",
"prefix": "ljust",
"body": "ljust"
},
"rjust": {
"description": "Filter |rjust",
"prefix": "rjust",
"body": "rjust"
},
"center": {
"description": "Filter |center:\"\"",
"prefix": "center",
"body": "center:\"$1\""
},
"cut": {
"description": "Filter |cut:\"\"",
"prefix": "cut",
"body": "cut:\"$1\""
},
"escape": {
"description": "Filter |escape",
"prefix": "escape",
"body": "escape"
},
"force_escape": {
"description": "Filter |force_escape",
"prefix": "force_escape",
"body": "force_escape"
},
"linebreaks": {
"description": "Filter |linebreaks",
"prefix": "linebreaks",
"body": "linebreaks"
},
"linebreaksbr": {
"description": "Filter |linebreaksbr",
"prefix": "linebreaksbr",
"body": "linebreaksbr"
},
"safe": {
"description": "Filter |safe",
"prefix": "safe",
"body": "safe"
},
"safeseq": {
"description": "Filter |safeseq",
"prefix": "safeseq",
"body": "safeseq"
},
"striptags": {
"description": "Filter |striptags",
"prefix": "striptags",
"body": "striptags"
},
"dictsort": {
"description": "Filter |dictsort",
"prefix": "dictsort",
"body": "dictsort"
},
"dictsortreversed": {
"description": "Filter |stuff:dictsortreversed",
"prefix": "dictsortreversed",
"body": "dictsortreversed"
},
"first": {
"description": "Filter |first",
"prefix": "first",
"body": "first"
},
"last": {
"description": "Filter |last",
"prefix": "last",
"body": "last"
},
"length": {
"description": "Filter |length",
"prefix": "length",
"body": "length"
},
"length_is": {
"description": "Filter |length_is",
"prefix": "length_is",
"body": "length_is"
},
"random": {
"description": "Filter |random",
"prefix": "random",
"body": "random"
},
"slice": {
"description": "Filter |slice",
"prefix": "slice",
"body": "slice"
},
"unordered_list": {
"description": "Filter |unordered_list",
"prefix": "unordered_list",
"body": "unordered_list"
},
"add": {
"description": "Filter |add",
"prefix": "add",
"body": "add"
},
"get_digit": {
"description": "Filter |get_digit",
"prefix": "get_digit",
"body": "get_digit"
},
"date": {
"description": "Filter |date",
"prefix": "date",
"body": "date"
},
"time": {
"description": "Filter |time",
"prefix": "time",
"body": "time"
},
"timesince": {
"description": "Filter |timesince",
"prefix": "timesince",
"body": "timesince"
},
"timeuntil": {
"description": "Filter |timeuntil",
"prefix": "timeuntil",
"body": "timeuntil"
},
"default": {
"description": "Filter |default:\"\"",
"prefix": "default",
"body": "default:\"$1\""
},
"default_if_none": {
"description": "Filter |default_if_none:\"\"",
"prefix": "default_if_none",
"body": "default_if_none:\"$1\""
},
"divisibleby": {
"description": "Filter |divisibleby",
"prefix": "divisibleby",
"body": "divisibleby"
},
"yesno": {
"description": "Filter |yesno",
"prefix": "yesno",
"body": "yesno"
},
"filesizeformat": {
"description": "Filter |filesizeformat",
"prefix": "filesizeformat",
"body": "filesizeformat"
},
"pluralize": {
"description": "Filter |pluralize",
"prefix": "pluralize",
"body": "pluralize"
},
"phone2numeric": {
"description": "Filter |phone2numeric",
"prefix": "phone2numeric",
"body": "phone2numeric"
},
"pprint": {
"description": "Filter |pprint",
"prefix": "pprint",
"body": "pprint"
}
}

View File

@ -1,524 +0,0 @@
{
"_comment" : "This section is autocomplete for django template tags",
"autoescape": {
"description": "{% autoescape %}",
"prefix": "autoescape",
"body": "{% autoescape ${1|off,on|} %}$0{% endautoescape %}"
},
"autoescape_paste": {
"description": "{% autoescape %} (paste)",
"prefix": "autoescape_paste",
"body": [
"{% autoescape ${1|off,on|} %}",
"$0${CLIPBOARD}",
"{% endautoescape %}"
]
},
"endautoescape": {
"description": "{% endautoescape %}",
"prefix": "endautoescape",
"body": "{% endautoescape %}"
},
"block": {
"description": "{% block name %}{% endblock name %}",
"prefix": "block",
"body": "{% block $1 %}$0{% endblock $1 %}"
},
"block_unnamed": {
"description": "{% block name %}{% endblock %}",
"prefix": "block_unnamed",
"body": "{% block $1 %}$0{% endblock %}"
},
"endblock": {
"description": "{% endblock %}",
"prefix": "endblock",
"body": "{% endblock %}"
},
"super": {
"description": "{{ block.super }}",
"prefix": "super",
"body": "{{ block.super }}"
},
"cache": {
"description": "{% cache %}{% endcache %}",
"prefix": "cache",
"body": "{% cache ${1:timeout} ${2:cache_name} ${3:dynamic_var} %}$0{% endcache %}"
},
"cache_selection": {
"description": "{% cache %} (selection) {% endcache %}",
"prefix": "cache_selection",
"body": [
"$0{% cache ${1:timeout} ${2:cache_name} ${3:dynamic_var} %}",
"\t${TM_SELECTED_TEXT}",
"$0{% endcache %}"
]
},
"startcache": {
"description": "{% cache %}",
"prefix": "startcache",
"body": "{% cache ${1:timeout} ${2:cache_name} ${3:dynamic_var} %}$0"
},
"endcache": {
"description": "{% endcache %}",
"prefix": "endcache",
"body": "{% endcache %}"
},
"comment_inline": {
"description": "{% comment %} (inline)",
"prefix": "comm",
"body": "{# $1 #}"
},
"comment": {
"description": "{% comment %}",
"prefix": "comment",
"body": "{% comment \"$1\" %}$0{% endcomment %}"
},
"comment_paste": {
"description": "{% comment %} (paste)",
"prefix": "comment",
"body": "{% comment %}${CLIPBOARD}{% endcomment %}"
},
"comment_selection": {
"description": "{% comment %} (selection)",
"prefix": "comment",
"body": [
"$0{% comment %}",
"\t${TM_SELECTED_TEXT}",
"$0{% endcomment %}"
]
},
"endcomment": {
"description": "{% endcomment %}",
"prefix": "endcomment",
"body": "{% endcomment %}"
},
"csrf_token": {
"description": "{% csrf_token %}",
"prefix": "csrf_token",
"body": "{% csrf_token %}"
},
"cycle": {
"description": "{% cycle %}",
"prefix": "cycle",
"body": "{% cycle $1 %}"
},
"debug": {
"description": "{% debug %}",
"prefix": "debug",
"body": "{% debug %}"
},
"extends": {
"description": "{% extends \"template_name.html\" %}",
"prefix": "extends",
"body": "{% extends \"$1.html\" %}$0"
},
"extends_var": {
"description": "{% extends variable %}",
"prefix": "extends_variable",
"body": "{% extends $1 %}$0"
},
"filter": {
"description": "{% filter filter_name %}",
"prefix": "filter",
"body": "{% filter $1 %}$0{% endfilter %}"
},
"endfilter": {
"description": "{% endfilter %}",
"prefix": "endfilter",
"body": "{% endfilter %}"
},
"firstof": {
"description": "{% firstof %}",
"prefix": "firstof",
"body": "{% firstof $1 as $2 %}"
},
"endfirstof": {
"description": "{% endfirstof %}",
"prefix": "endfirstof",
"body": "{% endfirstof %}"
},
"for": {
"description": "{% for %}",
"prefix": "for",
"body": "{% for $1 in $2 %}$0{% endfor %}"
},
"for_paste": {
"description": "{% for %} (paste)",
"prefix": "for_paste",
"body": "{% for $1 in $2 %}$3${CLIPBOARD}$0{% endfor %}"
},
"endfor": {
"description": "{% endfor %}",
"prefix": "endfor",
"body": "{% endfor %}"
},
"forempty": {
"description": "{% for %}{% empty %}{% endfor %}",
"prefix": "forempty",
"body": "{% for $1 in $2 %}$0{% empty %}$3{% endfor %}"
},
"forempty_paste": {
"description": "{% for %}(paste){% empty %}{% endfor %}",
"prefix": "forempty_paste",
"body": "{% for $1 in $2 %}$3${CLIPBOARD}{% empty %}$0{% endfor %}"
},
"if": {
"description": "{% if condition %}",
"prefix": "if",
"body": "{% if $1 %}$0{% endif %}"
},
"if_paste": {
"description": "{% if condition %} (paste)",
"prefix": "if_paste",
"body": "{% if $1 %}$0${CLIPBOARD}{% endif %}"
},
"ifelse": {
"description": "{% if condition %}{% else %}{% endif %}",
"prefix": "ifelse",
"body": "{% if $1 %}$2{% else %}$3{% endif %}"
},
"ifelse_paste": {
"description": "{% if condition %}(paste){% else %}{% endif %}",
"prefix": "ifelse_paste",
"body": "{% if $1 %}$2${CLIPBOARD}{% else %}$3{% endif %}"
},
"elif": {
"description": "{% elif condition %}",
"prefix": "elif",
"body": "{% elif $1 %}"
},
"else": {
"description": "{% else %}",
"prefix": "else",
"body": "{% else %}"
},
"endif": {
"description": "{% endif %}",
"prefix": "endif",
"body": "{% endif %}"
},
"ifchanged": {
"description": "{% ifchanged %}",
"prefix": "ifchanged",
"body": "{% ifchanged $1 %}$0{% endifchanged %}"
},
"endifchanged": {
"description": "{% endifchanged %}",
"prefix": "endifchanged",
"body": "{% endifchanged %}"
},
"include": {
"description": "{% include %}",
"prefix": "include",
"body": "{% include \"$1\" %}"
},
"include_with": {
"description": "{% include with var=value %}",
"prefix": "include_with",
"body": "{% include with $1=$2 %}"
},
"load": {
"description": "{% load tags %}",
"prefix": "load",
"body": "{% load ${1|static,i18n,cache,l10n,tz,humanize,flatpages|} %}"
},
"lorem": {
"description": "{% lorem %}",
"prefix": "lorem",
"body": "{% lorem ${1|1,2,3,4,5,6,7,8,9|} ${2|b,p,w|} ${3:random }%}"
},
"now": {
"description": "{% now %}",
"prefix": "now",
"body": "{% now \"${1|DATE_FORMAT,DATETIME_FORMAT,SHORT_DATE_FORMAT,SHORT_DATETIME_FORMAT,Y-m-d H:i|}\" %}"
},
"regroup": {
"description": "{% regroup %}",
"prefix": "regroup",
"body": "{% regroup $1 by $2 as ${3:_list} %}"
},
"regroup_example": {
"description": "{% regroup %}",
"prefix": "regroup_example",
"body": [
"{% regroup ${1:object_list} by ${2:category} as ${2:category}_list %}",
"<ul>",
" {% for ${2:category}, ${3:obj}_list in ${2:category}_list %}",
" <li>{{ ${2:category} }}",
" <ul>",
" {% for ${3:obj} in ${3:obj}_list %}",
" <li>{{ ${3:obj} }}</li>",
" {% endfor %}",
" </ul>",
" </li>",
" {% endfor %}",
"</ul>"
]
},
"resetcycle": {
"description": "{% resetcycle %}",
"prefix": "resetcycle",
"body": "{% resetcycle %}"
},
"spaceless": {
"description": "{% spaceless %}",
"prefix": "spaceless",
"body": "{% spaceless %}$0{% endspaceless %}"
},
"spaceless_paste": {
"description": "{% spaceless %} (paste)",
"prefix": "spaceless_paste",
"body": [
"{% spaceless %}",
"${CLIPBOARD}$0",
"{% endspaceless %}"
]
},
"endspaceless": {
"description": "{% endspaceless %}",
"prefix": "endspaceless",
"body": "{% endspaceless %}"
},
"static": {
"prefix": "{% static %}",
"description": "static",
"body": "{% static \"${1:$SELECTION}\" %}"
},
"tag": {
"description": "{% tag %}",
"prefix": "tag",
"body": "{% $1 %}"
},
"templatetag": {
"description": "{% templatetag %}",
"prefix": "templatetag",
"body": "{% templatetag ${1|openblock,closeblock,openvariable,closevariable,openbrace,closebrace,opencomment,closecomment|} %}"
},
"trans": {
"description": "{% trans \"text to translate\" %}",
"prefix": "trans",
"body": "{% trans \"${0:$SELECTION}\" %}"
},
"trans_paste": {
"description": "{% trans \"(paste)\" %}",
"prefix": "trans_paste",
"body": "{% trans \"${CLIPBOARD}\" %}"
},
"blocktrans": {
"description": "{% blocktrans %}text to translate{% endblocktrans %}",
"prefix": "blocktrans",
"body": "{% blocktrans %}$0{% endblocktrans %}"
},
"blocktrans_paste": {
"description": "{% blocktrans %}(paste){% endblocktrans %}",
"prefix": "blocktrans_paste",
"body": [
"{% blocktrans ${2:trimmed }%}",
"$0${CLIPBOARD}",
"{% endblocktrans %}"
]
},
"blocktrans_with": {
"description": "{% blocktrans with %}text to translate{% endblocktrans %}",
"prefix": "blocktrans_with",
"body": "{% blocktrans with $1=$2 ${3:trimmed }%}$0{% endblocktrans %}"
},
"blocktrans_with_paste": {
"description": "{% blocktrans with %}(paste){% endblocktrans %}",
"prefix": "blocktrans_with_paste",
"body": ["{% blocktrans with $1=$2 ${3:trimmed }%}",
"$0${CLIPBOARD}",
"{% endblocktrans %}"
]
},
"translate": {
"description": "{% translate \"text to translate\" %}",
"prefix": "translate",
"body": "{% translate \"${0:$SELECTION}\" %}"
},
"translate_paste": {
"description": "{% translate \"(paste)\" %}",
"prefix": "translate_paste",
"body": "{% translate \"${CLIPBOARD}\" %}"
},
"blocktranslate": {
"description": "{% blocktranslate %}text to translate{% endblocktranslate %}",
"prefix": "blocktranslate",
"body": "{% blocktranslate %}$0{% endblocktranslate %}"
},
"blocktranslate_paste": {
"description": "{% blocktranslate %}(paste){% endblocktranslate %}",
"prefix": "blocktranslate_paste",
"body": [
"{% blocktranslate ${2:trimmed }%}",
"$0${CLIPBOARD}",
"{% endblocktranslate %}"
]
},
"blocktranslate_with": {
"description": "{% blocktranslate with %}text to translate{% endblocktranslate %}",
"prefix": "blocktranslate_with",
"body": "{% blocktranslate with $1=$2 ${3:trimmed }%}$0{% endblocktranslate %}"
},
"blocktranslate_with_paste": {
"description": "{% blocktranslate with %}(paste){% endblocktranslate %}",
"prefix": "blocktranslate_with_paste",
"body": ["{% blocktranslate with $1=$2 ${3:trimmed }%}",
"$0${CLIPBOARD}",
"{% endblocktranslate %}"
]
},
"url": {
"description": "{% url \"some-url-name\" %}",
"prefix": "url",
"body": "{% url \"$1\" %}"
},
"urlpk": {
"description": "{% url \"some-url-name\" pk=object.pk %}",
"prefix": "urlpk",
"body": "{% url \"$1\" pk=${2:${3:object}.pk} %}"
},
"urlslug": {
"description": "{% url \"some-url-name\" slug=object.slug %}",
"prefix": "urlslug",
"body": "{% url \"$1\" slug=${2:${3:object}.slug} %}"
},
"urlvar": {
"description": "{% url \"some-url-name\" as the_url %}",
"prefix": "urlvar",
"body": "{% url \"$1\" as $2 %}"
},
"variable": {
"description": "{{ variable }}",
"prefix": "variable",
"body": "{{ $1 }}"
},
"variable_default": {
"description": "{{ variable|default:\"default value\" }}",
"prefix": "variable_default",
"body": "{{ $1|default:\"$2\" }}"
},
"verbatim": {
"description": "{% verbatim name %}some content{% endverbatim name %}",
"prefix": "verbatim",
"body": "{% verbatim $1 %}$0{% endverbatim $1 %}"
},
"verbatim_paste": {
"description": "{% verbatim %} (paste)",
"prefix": "verbatim_paste",
"body": "{% verbatim $1 %}$0${CLIPBOARD}{% endverbatim $1 %}"
},
"endverbatim": {
"description": "{% endverbatim %}",
"prefix": "endverbatim",
"body": "{% endverbatim $1%}"
},
"widthratio": {
"description": "{% widthratio %}",
"prefix": "widthratio",
"body": "{% widthratio ${1:this_value} ${2:max_value} ${3:max_width} ${4:as ${5:width}}%}"
},
"with": {
"description": "{% with key=value %}",
"prefix": "with",
"body": "{% with $1=$2 %}$0{% endwith %}"
},
"endwith": {
"description": "{% endwith %}",
"prefix": "endwith",
"body": "{% endwith %}"
},
"with_selection": {
"description": "{% with key=value %} (selection)",
"prefix": "with_selection",
"body": [
"$0{% with $1=$2 %}",
"\t${TM_SELECTED_TEXT}",
"$0{% endwith %}"
]
},
"with_paste": {
"description": "{% with key=value %} (paste)",
"prefix": "with_paste",
"body": "{% with $1=$2 %}${CLIPBOARD}{% endwith %}"
}
}

Some files were not shown because too many files have changed in this diff Show More