I'm trying to exclude files form being watched besides folder app in watchOptions in ESLint.
My folder structure looks like:
├── assets
│ ├── assets
│ │ └── fonts
│ │ ├── FeatherIcons
│ │ ├── Icomoon
│ │ └── Montserrat
│ ├── images
│ ├── imagesNotOptimized
│ ├── js
│ │ ├── app
│ │ │ ├── api
│ │ │ │ ├── erpFlex
I would like to include all the files inside app but ignore all other files.
config.watchOptions = {
poll: true,
ignored: [
path.resolve(__dirname, 'node_modules'),
path.resolve(__dirname, 'assets/js/*!(app)'),
]
};
I have tried the following regexes
assets/js/*(!app)
assets/js/(?!app)
Nothing seems to work. Any help would be much appreciated. Thank you
EDIT
I have been able to match the string using the following regex: https://regex101.com/r/hs4lOt/1
but path.resolve(__dirname, 'assets/js/(?!app).*') is not working which makes this question not about regex but why ignored is not working in watchOptions
Related
I've been digging through articles and posts about this subject but can't seem to get my images to load. For some reason the CSS on my pages seems to load just fine.
settings.py
BASE_DIR = Path(__file__).resolve().parent.parent
STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'static')
also I tried
STATIC_ROOT = '/var/www/myname/'
template
<img src="{% static 'picture.jpg' %}" class="img-fluid">
NGINX
/etc/nginx/sites-enabled/django_project
server {
listen 80;
server_name mywebsite.com;
location /static/ {
alias /var/www/myname/static/;
}
}
directories
/var/www/myname
└── static
└── admin
├── css
│ ├── styles1.css
│ └── styles2.css
├── images
│ ├── picture.jpg
│ └── python.jpg
└── js
└── scripts.js
/home/myname/myprojectdir
├── django_project
│ ├── django_project
│ │ └── __pycache__
│ ├── etc
│ ├── index
│ │ ├── migrations
│ │ │ └── __pycache__
│ │ ├── __pycache__
│ │ └── templates
│ │ └── index
│ │ └── backups
│ ├── __pycache__
│ └── static
│ ├── admin
│ │ ├── css
│ │ │ └── vendor
│ │ │ └── select2
│ │ ├── fonts
│ │ ├── images
│ │ │ └── gis
│ │ ├── img
│ │ │ └── gis
│ │ └── js
│ │ ├── admin
│ │ └── vendor
│ │ ├── jquery
│ │ ├── select2
│ │ │ └── i18n
│ │ └── xregexp
│ ├── images
│ └── index
│ ├── css
│ ├── images
│ └── js
├── myname_env
│ ├── bin
│ └── lib
│ └── python3.10
│ └── site-packages
└── static
└── admin
├── css
│ └── vendor
│ └── select2
├── fonts
├── img
│ └── gis
└── js
├── admin
└── vendor
├── jquery
├── select2
│ └── i18n
└── xregexp
I've tried installing the static files in other directories, etc, to see what works but I'm not having any luck whatsoever. I had the static files in the project but after reading that's not a good practice I put them into var/www.
can you add this into nginx conf and try:
location /images/ {
alias /var/www/myname/static/images;
}
I am trying to do a batch rename of files with rename. I can execute most of my changes but one is eluding me.
I am using this
find cracking-the-coding-interview -execdir rename 'y/---/-/' '{}' \+
The idea works fine for other regex, but this replacement does nothing. I tried replacing with a different item instead of dash
y/---/a/
and it replaced every dash with an a! not just those three connected. I also tried
'y/-{3}/-/'
I have a file structure something like this:
├── cracking-the-coding-interview
│ ├── algorithms
│ │ ├── bfs---shortest-reach-in-a-graph
│ │ │ ├── description.md
│ │ │ ├── solution.java
│ │ │ └── solution.js
│ │ ├── binary-search---ice-cream-parlor
│ │ │ ├── description.md
│ │ │ └── solution.js
│ │ ├── dfs---connected-cell-in-a-grid
I'm building a custom opencart payment extension (ocmod installable), I need to use an external payment provider sdk (located in the vendor folder) but i don't know how include this files on my packaged extension
This is my folder structure
..
├── install.xml
└── upload
├── admin
├── catalog
├── composer.json
├── image
└── vendor
To develop a payment extention for opencart, follow this structure
admin
│ ├── controller
│ │ ├── payment
│ │ │ ├── custom_payment.php
language
│ │ └── en-GB
│ │ ├── payment
│ │ │ ├── custom_payment.php
template
├── payment
│ ├── custom_payment.tpl
catalog/
├── controller
│ ├── payment
│ │ ├── custom_payment.php
├── language
│ └── en-GB
│ ├── payment
│ │ ├── custom_payment.php
├── model
│ ├── payment
│ │ ├── custom_payment.php
└── view
└── theme
├── default / your_theme
│ └── template
├── payment
│ ├── custom_payment.tpl
I have a working test suite using Pytest on a fairly large django project. Problem is I am unable to achieve proper results using coverage, and I am wondering if it may be because of the projects directory structure.
Consider the following sample of the directory tree:
.
├── apps
│ ├── api
│ │ ├── __init__.py
│ │ ├── tests
│ │ │ ├── __init__.py
│ │ │ └── views
│ │ │ ├── __init__.py
│ │ │ └── test_tickets.py
│ │ └── views
│ │ ├── __init__.py
│ │ ├── tickets.py
│ ├── support
│ │ ├── __init__.py
│ │ ├── tests
│ │ │ ├── __init__.py
│ │ │ └── utils
│ │ │ ├── __init__.py
│ │ │ ├── test_management_commands.py
│ │ ├── utils
│ │ │ ├── __init__.py
│ │ │ ├── management_commands.py
And a sample output of the coverage report:
coverage run --source apps/ -m py.test apps/
coverage report
Name Stmts Miss Cover
---------------------------------------------------------------
apps/api/views/tickets.py 42 18 57%
apps/support/utils/management_commands.py 135 100 26%
Looking at the html report I can see many statements executed by the tests are not considered covered, even though they should be. I believe this coverage data to be incomplete, it seems to only be considering imports, definitions, and docstrings as covered.
Unable to determine why the coverage appeared incorrect, I tried running a single test module, with positive results:
coverage run --source apps/support/utils/management_commands.py -m py.test apps/support/tests/utils/test_management_commands.py
coverage report
Name Stmts Miss Cover
---------------------------------------------------------------
apps/support/utils/management_commands.py 135 68 50%
This is more accurate, the HTML report shows the statement I have tests for are indicated as covered this time. Unable to figure out why running a single test module yields accurate results, I modified the directory structure by moving the tests under a single parent folder.
.
├── apps
│ ├── api
│ │ ├── __init__.py
│ │ └── views
│ │ ├── __init__.py
│ │ ├── tickets.py
│ ├── support
│ │ ├── __init__.py
│ │ ├── utils
│ │ │ ├── __init__.py
│ │ │ ├── management_commands.py
├── tests
│ │ ├── __init__.py
│ ├── api
│ │ ├── __init__.py
│ │ └── views
│ │ ├── __init__.py
│ │ └── test_tickets.py
│ ├── support
│ │ ├── __init__.py
│ │ ├── utils
│ │ │ ├── __init__.py
│ │ │ ├── test_management_commands.py
Re-running coverage with this directory structure yields more accurate results:
coverage run --source apps/ -m py.test tests/
coverage report
Name Stmts Miss Cover
---------------------------------------------------------------
apps/api/views/tickets.py 42 0 100%
apps/support/utils/management_commands.py 135 68 50%
Can anyone explain why running coverage with py.test was yielding in complete coverage under the original directory structure? Was the directory structure actually the problem or am I missing something else here?
Additional info:
# pytest.ini
[pytest]
addopts = --nomigrations
markers =
slowtest: mark a test as being slow
integration: mark a test as being an integration test
INSTALLED_APPS += ('django_coverage', )
TEST_DISCOVER_PATTERN = 'test_*'
COVERAGE_MODULE_EXCLUDES = [
'settings',
'urls$',
'locale$',
'tests$',
'django',
'migrations',
'compressor',
'templates?$',
'fixtures$',
'static$',
]
ROOT_PATH = os.path.abspath('%s/' % os.path.dirname(__file__))
The .coveragerc
[run]
source = apps
omit =
apps/*/templates?/*
apps/*/migrations/*
apps/*/factories/*
apps/*/tests/*
[html]
directory = coverage
Module versions (some may be unrelated):
pytest==2.9.0
pytest-cov==2.2.1
pytest-django==2.9.1
django-coverage==1.2.4
coverage==4.0.3
I see I'm a little late to the party (3-year-old question with no accepted answer yet), but since I've just had this same question with a seemingly obvious answer: coverage will only report on code that is actually run. So if your tests don't call a bit of code and it doesn't get run during normal loading of the application, coverage will not show a report for that code. Code that doesn't run does not cause bugs :)
I know there is a plethora of questions related to this, like this one, but I does not seem to help.
My question is simple, given this function signature, how do I override the view profile_detail? I seem to be doing everything exactly as both resources say, but my templates are still not receiving the extra context. Here's what I am trying to do:
# This overrides and extends userena's view named 'profile_detail'.
def profileDetailView(request, username):
# Do some logic, etc.
foo_list = Some.objects.filter(id=username)
extra_context = {'foo_list': foo_list}
# I have also tried the following for extra_context:
extra_context['foo_list'] = foo_list
return userena_views.profile_detail(request, username, template_name='userena/profile_detail.html',
extra_context=extra_context)
I am not sure where I am going wrong. I have my URL's correct, as it is loading my views without error. Also, I have tested through the shell to create foo_list by import objects - it worked. I have also done a test to make sure the username being passed in actually results in an object being found. Thus - it seems like the only problem could be in the extra_context, at least I hope! Any help would be much appreciated!
EDIT: File structure Request
├── project
│ ├── __init__.py
│ ├── __init__.pyc
│ ├── models.py
│ ├── models.pyc
│ ├── settings.py
│ ├── settings.pyc
│ ├── static
│ │ ├── css
│ │ │ └─
│ │ └── js
│ ├── test.py
│ ├── urls.py
│ ├── urls.pyc
│ ├── wsgi.py
│ └── wsgi.pyc
├── manage.py
├── media
├── templates
│ ├── admin
│ │ └── base_site.html
│ ├── base_site.html
│ ├── errors
│ │ └── not_authorized.html
│ └── userena
│ ├── base.html
│ ├── base_userena.html
│ ├── profile_detail.html
│ ├── profile_details.html
│ └── signup_form.html
└── utils
TEMPLATE_DIRS = (
'/home/username/project/project/templates',
)